group by and one column per month?

Поиск
Список
Период
Сортировка
От Harald Lux
Тема group by and one column per month?
Дата
Msg-id 3C586F67.29034.255827@localhost
обсуждение исходный текст
Ответы Re: group by and one column per month?  (Torbjörn Andersson <tobbe@embryo.se>)
Список pgsql-novice
given a table with these fields:

dealer char()
revenue float()
vdate date

now:

select dealer, sum(revenue)
    from table
group by dealer

and also:

select dealer, sum(revenue)
    from table where date_part('month', vdate) = 1
group by dealer

work fine.

But instead of one column with the whole revenue (first example) or the renvenue of one month
(second example) I would like to have a column for each month. is this possible within one select
statement?

TIA
Harald
--
Harald Lux                      lux@lux.de
Sandkaule 5-7                   Tel.: +49 228 692325
D-53111 Bonn                    http://www.lux.de/


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

Предыдущее
От: "postgresql"
Дата:
Сообщение: Re: ^[[A
Следующее
От: Torbjörn Andersson
Дата:
Сообщение: Re: group by and one column per month?