How do I solve this efficiently?

Поиск
Список
Период
Сортировка
Искать
От
elwood@agouros.de (Konstantinos Agouros)
Тема
How do I solve this efficiently?
Дата
Msg-id
elwood.980607938@news.agouros.de
Список
Дерево обсуждения
How do I solve this efficiently? elwood@agouros.de (Konstantinos Agouros)
Re: How do I solve this efficiently? "Oliver Elphick" <olly@lfix.co.uk>
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@agouros.de
Otkerstr. 28, 81547 Muenchen, Germany. Tel +49 89 69370185
----------------------------------------------------------------------------
"Captain, this ship will not sustain the forming of the cosmos." B'Elana Torres
В списке pgsql-general по дате отправления
От: Jeffery Jansen
Дата:
Сообщение:
От: Matt Friedman
Дата:
FAQ