Re: From CROSSTAB: One Column data with Two results columns

From: M Sarwar <sarwarmd02(at)outlook(dot)com>
To: Andreas Wagner <thewand(at)web(dot)de>, "pgsql-admin(at)lists(dot)postgresql(dot)org" <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: From CROSSTAB: One Column data with Two results columns
Date: 2024-04-15 19:42:48
Message-ID: DM4PR19MB5978DB4374B1D9245124EE38D3092@DM4PR19MB5978.namprd19.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin


Hello Mr. Andreas,
( Just correcting the title / Sorry for my bad. )

You are using my name perfectly.
In the CROSSTAB clause, there are 3 sections.

1.
Row columns
2.
Category column
3.
Data / Results columns

CROSSTAB provides option to fetch just 1 column while using CROSSTAB in normal circumstances.
My question is 'is there anyway that I can fetch 2 columns?'.
I am sharing the pictorial diagram where I need to fetch 2 columns data / results for the same category columns ( TEST1P1, TEST1P2, TEST1P3, TEST1P4 ).

[cid:bb7473d7-d1c3-439a-96ab-1de0d82dc9f5]

Thank you,
Sarwar

________________________________
From: Andreas Wagner <thewand(at)web(dot)de>
Sent: Monday, April 15, 2024 1:41 PM
To: M Sarwar <sarwarmd02(at)outlook(dot)com>; pgsql-admin(at)lists(dot)postgresql(dot)org <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: From CROSSTAB: One Column data with Two results columns

Hello Mr. Sarwar!

I'm not certain about first and last names in foreign countries, so my
apologies if it's your first name.

Am Montag, dem 15.04.2024 um 12:25 +0000 schrieb M Sarwar:
>
> Hello Andreas,
> Using a function, I am generating CROSSTAB SQL and the number of
> columns will vary for each execution. With that, it is extremely
> difficult to use view on this task.

I'm still not sure whether I understand your question. You look for a
way to produce statements like

SELECT test1p1.data, test1p2.data, test1p3.data,
f(test1p1.data), f(test1p2.data), f(test1p3.data)
FROM test1p1, test1p2, test1p3;

programmatically? ("f()" is a user-defined function deriving the left
values on the sample-picture to the right values.)

In case using multiple tables is new to you, have a look at the "JOIN"-
statement.

Regards,
Andreas Wagner

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Oracle People 2024-04-15 20:48:04 Re: ERROR could not read block xxx in file, read only 0 of 8192 bytes
Previous Message M Sarwar 2024-04-15 19:31:22 Re: From CROSSTAB: One Column data with Two results columns