group by and one column per month?

From: "Harald Lux" <info(at)lux(dot)de>
To: pgsql-novice(at)postgresql(dot)org
Subject: group by and one column per month?
Date: 2002-01-30 21:10:47
Message-ID: 3C586F67.29034.255827@localhost
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)lux(dot)de
Sandkaule 5-7 Tel.: +49 228 692325
D-53111 Bonn http://www.lux.de/

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Torbj=?ISO-8859-1?B?9g==?=rn Andersson 2002-01-30 21:37:24 Re: group by and one column per month?
Previous Message postgresql 2002-01-30 19:51:48 Re: ^[[A