From: | Majid Khan <mk(dot)swati(at)gmail(dot)com> |
---|---|
To: | pgsql-sql(at)postgresql(dot)org |
Subject: | Fwd: Re: crosstab category mix |
Date: | 2017-06-16 12:35:40 |
Message-ID: | CADbhJ9rYoSPJTNPXdmqtFp-nnD78La2fA+aJMw6_q1diuoZhOw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
---------- Forwarded message ----------
From: "Majid Khan" <mk(dot)swati(at)gmail(dot)com>
Date: Jun 12, 2017 20:48
Subject: Re: [SQL] crosstab category mix
To: "Steve Midgley" <science(at)misuse(dot)org>
Cc:
hi,
thanks for response. Here attached is the data with actual summary and
query result.Also I am applying the following query.
*SELECT * FROM crosstab('SELECT*
*survey_date,*
*district,*
*total*
*FROM*
*sample') AS ct(survey_date varchar, khuzdar NUMERIC ,loralai NUMERIC,zhob
NUMERIC);*
Regards,
Majid
On Mon, Jun 12, 2017 at 6:46 PM, Steve Midgley <science(at)misuse(dot)org> wrote:
>
>
> On Jun 12, 2017 12:53 AM, "Majid Khan" <mk(dot)swati(at)gmail(dot)com> wrote:
>
> Hi,
> favorite
> <https://stackoverflow.com/questions/44487568/postgres-cross-tabs-mixes-categories-in-result-set#>
>
> 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
>
>
> Please provide sample data and sql to allow us to see where your problem
> is.
>
> Steve
>
Attachment | Content-Type | Size |
---|---|---|
data.xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | 13.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Samed YILDIRIM | 2017-06-16 15:03:43 | Re: crosstab category mix |
Previous Message | Steve Midgley | 2017-06-12 13:46:51 | Re: crosstab category mix |