X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D1A9956B4A for ; Mon, 21 Mar 2005 23:43:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 27238-09 for ; Mon, 21 Mar 2005 23:43:41 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 4841356B6C for ; Mon, 21 Mar 2005 23:42:50 +0000 (GMT) Received: from viper.net.nih.gov (mailfwd.nih.gov [165.112.130.32]) by svr4.postgresql.org (Postfix) with ESMTP id 61ABA5AF039 for ; Mon, 21 Mar 2005 23:32:56 +0000 (GMT) Received: from viper.net.nih.gov (localhost [127.0.0.1]) by viper.net.nih.gov (8.12.10/8.12.8p1) with ESMTP id j2LNRmhb018827 for ; Mon, 21 Mar 2005 18:27:48 -0500 Received: from WATSON (vpn-165-112-10-41.net.nih.gov [165.112.10.41]) by viper.net.nih.gov (8.12.10/8.12.8p1) with SMTP id j2LNReN3018753; Mon, 21 Mar 2005 18:27:47 -0500 Message-ID: <002d01c52e6d$93e02360$1f6df345@WATSON> From: "Sean Davis" To: "Thomas Borg Salling" , References: <20050321215723.E79E356388@svr1.postgresql.org> Subject: Re: "Flattening" query result into columns Date: Mon, 21 Mar 2005 18:27:41 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_002A_01C52E43.AAD80EE0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.141 tagged_above=0 required=5 tests=AWL, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200503/289 X-Sequence-Number: 20768 This is a multi-part message in MIME format. ------=_NextPart_000_002A_01C52E43.AAD80EE0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thomas, You probably want a crosstab. There is a contributed module in = contrib/crosstab. If you do a search of the postgres mailing lists, = there will be several posts relating to the same issue. Sean ----- Original Message -----=20 From: Thomas Borg Salling=20 To: pgsql-sql@postgresql.org=20 Sent: Monday, March 21, 2005 4:57 PM Subject: [SQL] "Flattening" query result into columns I am looking for a way to "flatten" a query result, so that rows are = "transposed" into columns, just as asked here for oracle: = http://groups.google.dk/groups?hl=3Dda&lr=3D&client=3Dfirefox-a&rls=3Dorg= .mozilla:en-US:official&selm=3Daad10be0.0401292322.7b6c320b%40posting.goo= gle.com =20 Is there any way to do this with pgsql ? =20 Thanks, /Thomas. =20 =20 ------=_NextPart_000_002A_01C52E43.AAD80EE0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thomas,
 
You probably want a crosstab.  = There is a=20 contributed module in contrib/crosstab.  If you do a search of the = postgres=20 mailing lists, there will be several posts relating to the same=20 issue.
 
Sean
 
----- Original Message -----
From:=20 Thomas Borg = Salling=20
Sent: Monday, March 21, 2005 = 4:57=20 PM
Subject: [SQL] "Flattening" = query result=20 into columns

I am looking for a way = to=20 =94flatten=94 a query result, so that rows are =94transposed=94 into = columns, just as=20 asked here for oracle:

http://groups.google.dk/groups?hl=3Dda&a= mp;lr=3D&client=3Dfirefox-a&rls=3Dorg.mozilla:en-US:official&= selm=3Daad10be0.0401292322.7b6c320b%40posting.google.com

 

Is there any way to do = this with=20 pgsql  ?

 

Thanks,

/Thomas.

 

 

------=_NextPart_000_002A_01C52E43.AAD80EE0--