Problem with pivot tables - Mailing list pgsql-sql

From Gabriel Filipiak
Subject Problem with pivot tables
Date
Msg-id CALy5J6WK__RhmnYvtsm0Jnj=aPv+=do32o=fdTk0Zh1V18rCrw@mail.gmail.com
Whole thread Raw
Responses Re: Problem with pivot tables  (Samuel Gendler <sgendler@ideasculptor.com>)
List pgsql-sql
I have problem with creating a pivot table in postgreSQL using crosstab function. It works well but it produces many
recordsfor the same client_id, how can I avoid it?<br /><br />Here is the SQL:<br /><br />SELECT * FROM
crosstab('SELECTclient_id,extract(year from date), sum(amount)  from orders group by extract(<br /> year from date),
client_id','SELECTextract(year from date) FROM orders GROUP BY extract(year from date) order by extract(year from
date)')<br/>AS orders(<br />row_name integer, <br />year_2001 text, <br />year_2002 text, <br /> year_2003 text, <br
/>year_2004text, <br />year_2005 text, <br />year_2006 text, <br />year_2007 text, <br />year_2008 text, <br
/>year_2009text, <br />year_2010 text, <br />year_2011 text);    <br /><br />best regard and thx in advance<br />
Gabe<br/> 

pgsql-sql by date:

Previous
From: Craig Ringer
Date:
Subject: Re: How to implement Aggregate Awareness?
Next
From: Samuel Gendler
Date:
Subject: Re: Problem with pivot tables