Re: pivoting data?

Поиск
Список
Период
Сортировка
От Joy Smith
Тема Re: pivoting data?
Дата
Msg-id CAJqhhiP5ZXt-O+f07EGoMXbpU0qmmb+Ymq9eJuVrKVTVXYqfAg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pivoting data?  (Joy Smith <freestuffanddeals@gmail.com>)
Список pgsql-general
>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

В списке pgsql-general по дате отправления:

Предыдущее
От: Lincoln Yeoh
Дата:
Сообщение: Re: conditional insert
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: conditional insert