| From: | "Michael L(dot) Hostbaek" <mich(at)the-lab(dot)org> |
|---|---|
| To: | Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Group by and aggregates |
| Date: | 2004-11-05 14:51:46 |
| Message-ID: | 20041105145146.GB47770@mich2.itxmarket.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | SZŰCS Gábor | 2004-11-05 14:52:39 | Killed backend won't rollback transaction? |
| Previous Message | Igor Maciel Macaubas | 2004-11-05 14:35:58 | Help in stored procedure |