Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f4MEbfA87725 for ; Tue, 22 May 2001 10:37:41 -0400 (EDT) (envelope-from pgsql-sql-owner@postgresql.org) Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4KJvYA50791 for ; Sun, 20 May 2001 15:57:34 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.1/8.11.1) id f4KJdxr53351 for pgsql-sql@postgresql.org; Sun, 20 May 2001 15:39:59 -0400 (EDT) (envelope-from news) From: =?iso-8859-1?Q?Hans=2DJ=FCrgen=20Sch=F6nig?= X-Newsgroups: comp.databases.postgresql.sql Subject: Transposing data Date: Sun, 20 May 2001 21:42:37 +0200 Organization: Hub.Org Networking Services (http://www.hub.org) Lines: 24 Message-ID: <3B081E2D.BB24DBE3@cybertec.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: scrappy@hub.org X-Mailer: Mozilla 4.77 [de] (X11; U; Linux 2.4.2-2 i686) X-Accept-Language: en To: pgsql-sql@postgresql.org X-Archive-Number: 200105/244 X-Sequence-Number: 3064 I want the values in column label to be displayed in the a-axis. Is there an easy way to transform the data: Here is the input data: age_code | label | count ----------+-------+------- age_1 | 30k | 1 age_1 | 50k | 2 age_1 | more | 2 age_2 | 40k | 2 age_3 | 40k | 1 I want the result to be: age_code | 30k | 40k | 50k | more ----------------------- age_1 | 1 | | 2 | 1 age_2 | | 2 | age_3 | | 1 | | Is there any easy way to do the job or do I have to write a PL/pgSQL function? Hans