How do I solve this efficiently?

From: elwood(at)agouros(dot)de (Konstantinos Agouros)
To: pgsql-general(at)postgresql(dot)org
Subject: How do I solve this efficiently?
Date: 2001-01-27 15:10:00
Message-ID: elwood.980607938@news.agouros.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I have a table like the following :
Table "expenses"
Attribute | Type | Modifier
-----------+-------------+----------
datum | date |
ware | varchar(80) |
price | float4 |

To get a summary of what I spent in a month I do a:
select ware,sum(price) from ausgaben where datum >= '1-1-2000' and datum <
'2-1-2000';

Now I would like to have an overview for a year in the form:

Ware January February March ...
Food 50.0 40.0 60.0
CDs. 20.0 40.0

.....

What's the easiest way of doing this?
I would like to avoid creating to many temporary tables if possible.

Konstantin

--
Dipl-Inf. Konstantin Agouros aka Elwood Blues. Internet: elwood(at)agouros(dot)de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres

Browse pgsql-general by date

  From Date Subject
Next Message Culley Harrelson 2001-01-27 15:28:32 JDBC connection failure
Previous Message Dmitry Chernikov 2001-01-27 14:58:01