Re: [SQL] For each record in SELECT - Mailing list pgsql-general

From Andrew J. Kopciuch
Subject Re: [SQL] For each record in SELECT
Date
Msg-id 200301311936.18611.akopciuch@bddf.ca
Whole thread Raw
In response to For each record in SELECT  (Luis Magaña <joe666@gnovus.com>)
List 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 by date:

Previous
From: Keary Suska
Date:
Subject: Re: SQL-question (JOIN)
Next
From: Tom Lane
Date:
Subject: Re: create view ... select fld,'constant',fld ...