For each record in SELECT

Поиск
Список
Период
Сортировка
От Luis Magaña
Тема For each record in SELECT
Дата
Msg-id 1044048077.1380.3.camel@kerberus
обсуждение исходный текст
Ответы Re: For each record in SELECT  (Keary Suska <hierophant@pcisys.net>)
Re: [SQL] For each record in SELECT  ("Andrew J. Kopciuch" <akopciuch@bddf.ca>)
Re: [NOVICE] For each record in SELECT  (Andrew McMillan <andrew@catalyst.net.nz>)
Список pgsql-general
Hi,

I have a question here:

I have a table with this fields:

month
description
amount

now I have to write a query that retrieves the sum of the amount from
the minimum month to the maximum month registered for each diferent
description.

Of course there are cases when a particular description has not record
for all the months in that period.  I mean, suppouse you have this
records:

month    description    amount
-----------------------------------------------
June    description1    100
July    description1    500
August    description1    600
June    description2    300
August    description2    400

how you write a query that outputs something like this:

                June    July    August
------------------------------------------
description1 |    100    500    600
description2 |    300    0    400

My problem is for the 0 value.

I hope I've explained clearly my question.

Thanks for the help.

Best Regards.



--
Luis Magaña.
Gnovus Networks & Software.
www.gnovus.com


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Query performance PLEASE HELP
Следующее
От: pilsl@goldfisch.at
Дата:
Сообщение: SQL-question (JOIN)