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 12:25:55
Message-ID: DM4PR19MB5978C5982BF97D6DE105158AD3092@DM4PR19MB5978.namprd19.prod.outlook.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

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.
Thanks,
Sarwar

________________________________
From: Andreas Wagner <thewand(at)web(dot)de>
Sent: Monday, April 15, 2024 5:03 AM
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!

Am Sonntag, dem 14.04.2024 um 20:54 +0000 schrieb M Sarwar:
> Hi,
> I am working CROSSTAB functionality to generate the reports in the
> CSV format.
>
> Now I have stage where I need to generate 2 result sets for the same
> 1 column data.

Something like "CREATE VIEW"? The documentation has some useful
examples: https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.postgresql.org%2Fdocs%2Fcurrent%2Fsql-createview.html&data=05%7C02%7C%7C68ff07469622406ac6be08dc5d2af2f1%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638487686248203307%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=1NwPwfkyT9BBtzDrtrkVNOHbTFo5rcayKuaZm51pqq0%3D&reserved=0<https://www.postgresql.org/docs/current/sql-createview.html>

"CREATE PROCEDURE" and "CREATE FUNCTION" are rarely covered by
tutorials, so I mention them. They can be used in a similar manner.

For CSV, I'm the wrong person. I'd code it in C/C++.

Regards,
Andreas Wagner

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andreas Wagner 2024-04-15 17:41:47 Re: From CROSSTAB: One Column data with Two results columns
Previous Message Adrien Nayrat 2024-04-15 12:20:36 Re: ERROR could not read block xxx in file, read only 0 of 8192 bytes