Search Postgresql Archives

Re: pivoting data?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/08/2011 03:15 PM, Joy Smith wrote:
Hello Chris, yes that does seem to be a lot cleaner - though it does one thing that is not right - 
ie)
add to the previous data
 insert into modvalues (parties,baloons,color,dayofpurchase,amountpur) values
> ('1','big','red','1/2/2011',4);


then the output looks like:

baloons     color        jan first       jan second     jan third
big             red            7
big             green                           14
big                 blue                           3
big                  red                            4

instead of looking like this(having big red only show up once with the new value under jan second):

baloons     color        jan first       jan second     jan third
big             red            7                     4
big             green                           14
big                 blue                           3


thank you for your help and ideas
You'll want to group by baloons,color and probably take a sum of each of the case statements.

Sim

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux