Search Postgresql Archives

Re: pivoting data?

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

 



>You'll want to group by baloons,color and probably take a sum of each of the case statements.

>Sim

yes, hard to believe I did not notice that.  Thank you, the working query is:

select baloons, color,
max(case when dayofpurchase = '2011-01-01' then amountpur ELSE NULL END) as "first",
max(CASE when dayofpurchase = '2011-01-02' then amountpur ELSE NULL END) as "second",
max(CASE when dayofpurchase = '2011-01-03' then amountpur ELSE NULL END) as "third"
from modvalues
group by baloons, color

[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