[SQL] crosstab category mix - Mailing list pgsql-sql

From Majid Khan
Subject [SQL] crosstab category mix
Date
Msg-id CADbhJ9pVMtWixJGQQsY-N=gdHND65df56QYe8uUFpbWK5L7mpQ@mail.gmail.com
Whole thread Raw
Responses Re: [SQL] crosstab category mix  (Steve Midgley <science@misuse.org>)
List pgsql-sql
Hi,

I have a query returning me three columns 'Date', 'District' and 'Total'. There are four districts but some time a district may not have record for corresponding date. I want to put all my districts in column and their total in rows as ..

Date, District1, District2, District3, District4

While in my rows will be date along with the total value per district.

I am using crosstab to get the desired results. But in the result total for one district is listed in other district though the datewise grand total is same.

I don't know why crosstab query mixes categories. Please help.

Regards,
Majid

pgsql-sql by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: [SQL] Not getting the expected results for a simple where not in
Next
From: Steve Midgley
Date:
Subject: Re: [SQL] crosstab category mix