Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id D2D141337BEB for ; Thu, 17 Mar 2011 14:19:35 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 58341-05 for ; Thu, 17 Mar 2011 17:19:24 +0000 (UTC) X-Greylist: delayed 00:07:15.066354 by SQLgrey-1.7.6 Received: from mail03.insiderscore.com (mail03.insiderscore.com [72.5.31.50]) by mail.postgresql.org (Postfix) with ESMTP id 31D621337BE8 for ; Thu, 17 Mar 2011 14:19:24 -0300 (ADT) Received: from [192.168.0.100] (pool-173-61-101-104.cmdnnj.fios.verizon.net [173.61.101.104]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail03.insiderscore.com (Postfix) with ESMTP id 006AB178006F for ; Thu, 17 Mar 2011 13:12:07 -0400 (EDT) X-DomainKeys: Sendmail DomainKeys Filter v1.0.1 mail03.insiderscore.com 006AB178006F DomainKey-Signature: a=rsa-sha1; s=is; d=insiderscore.com; c=simple; q=dns; b=lDFiM7mXA++4W16htOLdCvJnSSkYy/gacd8bL9nyQf4E0TqscuI5jkVwgNRcV5s04 J0E2V6uDwiNRUJP1uJOgykuNGPLNq20F7YnQSUpk7z+opMO4RQeT11r8SyVA9fp Message-ID: <4D8240E7.1030008@insiderscore.com> Date: Thu, 17 Mar 2011 13:12:07 -0400 From: Richard Albright User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Re: How to transform table rows into Colum? References: <4D77B5FC.6010502@affinitas.de> In-Reply-To: <4D77B5FC.6010502@affinitas.de> Content-Type: multipart/alternative; boundary="------------060604070601040107060102" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.909 tagged_above=-5 required=5 tests=BAYES_00=-1.9, HTML_MESSAGE=0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201103/27 X-Sequence-Number: 35229 This is a multi-part message in MIME format. --------------060604070601040107060102 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit you can also generate a crosstab table using the sign function you can check out the link below ( its a sqlite tutorial, but the same idea will work for pg too ) http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html On 03/09/2011 12:16 PM, Eric Ndengang wrote: > Hi Guys, > I have the following table: > > Name Value rang salary > ------------------------------------ > name1 value1 1 2500 > name2 value2 2 2600 > name3 value 3 3 300 > > and want to obtain the following result: > > name1 name2 name3 > ------------------------------------ > value1 value2 value3 > 1 2 3 > 2500 2600 300 > > what should i do ? I read about the crosstab function in postgresql > but still have no idea on how to use it to solve this problem. > Any help would be appreciated > Regards > -- *Rick Albright* Senior Quantitative Analyst Web: www.insiderscore.com Email: ralbright@insiderscore.com --------------060604070601040107060102 Content-Type: text/html; charset=ISO-8859-15 Content-Transfer-Encoding: 8bit you can also generate a crosstab table using the sign function

you can check out the link below ( its a sqlite tutorial, but the same idea will work for pg too )

http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html


On 03/09/2011 12:16 PM, Eric Ndengang wrote:
Hi Guys,
I have the following table:

Name   Value   rang  salary
------------------------------------
name1   value1  1    2500
name2   value2  2    2600
name3   value 3 3    300

and want to obtain the following result:

name1  name2  name3
------------------------------------
value1  value2   value3
1             2            3
2500      2600    300

what should i do ? I read about the crosstab function  in postgresql but still have no idea on how to use it to solve this problem.
Any help would be appreciated
Regards



--
Rick Albright
Senior Quantitative Analyst
Web: www.insiderscore.com
Email: ralbright@insiderscore.com
--------------060604070601040107060102--