Is it possible in PostgreSQL?

From: "Bronx" <tobronx(at)go2(dot)pl>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Is it possible in PostgreSQL?
Date: 2004-01-12 23:58:52
Message-ID: 00ca01c3d968$07c05fe0$0201a8c0@bronx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

Hi,
I've got problem with one specific query. I've got the table
with many of rekords like these:

name | quantity | date
-------------------------------------------------------
aaa 2 2003-04-01
bbb 4 2003-04-12
ccc 5 2003-05-12
aaa 3 2003-01-14
aaa 1 2003-12-09
bbb 9 2003-08-08

and so on ...

Does anybody know how make query which return grouped
records by month of year and name (also sum of quantity).
It is possible to make a query whitch return something like that:

name | 01 | 02 | 03 | 04 | ... | 12 (months)
------------------------------------------------
aaa x x x x ... x
bbb x x x x ... x
ccc x x x x ... x

where x means sum of quantity in month.
It is possible to make it in one query?
I know that in Access is construction : PIVOT.

Thanks
Adam

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Hadley Willan 2004-01-13 01:17:23 7.4.1 and rhel2.1
Previous Message ListSrv 2004-01-12 22:44:47 Re: Tablerights for User in Group

Browse pgsql-sql by date

  From Date Subject
Next Message David Witham 2004-01-13 01:12:52 Transpose rows to columns
Previous Message katarn 2004-01-12 21:36:51 Re: Unique key field or serverl fks ?