PIVOT of data

From: Srikanth Rao <srirao_us(at)yahoo(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: PIVOT of data
Date: 2001-03-14 22:29:16
Message-ID: 20010314222916.11494.qmail@web6305.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,
I have a table like this:
location | numbrochures | marketing
-----------------------+--------------+-----------
101 Asheville, NC | 4 | NEWS
101 Asheville, NC | 1 | TV
101 Asheville, NC | 3 | RADIO
101 Asheville, NC | 2 | OTHER
101 Asheville, NC | 3 | null
101 Asheville, NC | 1 | TV
102 'Charlotte', 'NC' | 1 | SIGN
104 'Colfax', 'NC' | 5 | SIGN
109 'Moyock', 'NC' | 1 | BROCHURE
(9 rows)

I want the headings to be like:

location | NEWS | TV | RADIO | OTHER | ........

How to get this done using sql for postgresql backend?

TIA,
Sri.

__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices.
http://auctions.yahoo.com/

Browse pgsql-sql by date

  From Date Subject
Next Message George Young 2001-03-14 22:30:52 Re: need to join successive log entries into one
Previous Message Richard H 2001-03-14 21:36:35 Re: PL/pgSQL "compilation error"