Re: [SQL] For each record in SELECT

Поиск
Список
Период
Сортировка
От Andrew J. Kopciuch
Тема Re: [SQL] For each record in SELECT
Дата
Msg-id 200301311936.18611.akopciuch@bddf.ca
обсуждение исходный текст
Ответ на For each record in SELECT  (Luis Magaña <joe666@gnovus.com>)
Список pgsql-general
On Friday 31 January 2003 14:21, Luis Magaña wrote:
> 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.
>

From what I understand in your email you just need to add a GROUP BY clause.
Try a query like this.

SELECT description, sum(amount) FROM table GROUP BY description;


That should do what you need,



Andy


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

Предыдущее
От: Keary Suska
Дата:
Сообщение: Re: SQL-question (JOIN)
Следующее
От: Tom Lane
Дата:
Сообщение: Re: create view ... select fld,'constant',fld ...