Re: Group by and aggregates - Mailing list pgsql-sql

From Michael L. Hostbaek
Subject Re: Group by and aggregates
Date
Msg-id 20041105145146.GB47770@mich2.itxmarket.com
Whole thread Raw
In response to Re: Group by and aggregates  (Franco Bruno Borghesi <franco@akyasociados.com.ar>)
List pgsql-sql
Franco Bruno Borghesi (franco) writes:
> If I understand well, you want the highest cmup for each partno, that is
> max(cmup) grouped by partno (only).
>
> SELECT T.partno, T.status, TMP.max_cmup_for_partno, max(T.cmup) AS
> max_cmup, sum(T.qty) AS sum_qty
> FROM my_table T, (SELECT partno,    max(cmup) AS max_cmup_for_partno FROM
> my_table GROUP BY partno) AS TMP
> WHERE tmp.partno=T.partno
> GROUP BY T.partno, TMP.max_cmup_for_partno, T.status
>
> Hope it helped.

This worked out nicely. Thank you very much !

/mich

pgsql-sql by date:

Previous
From: Flavio Fonseca
Date:
Subject: sql problem
Next
From: Thomas F.O'Connell
Date:
Subject: Re: Help in stored procedure