From: Michael L. Hostbaek <mich@the-lab.org>
To: Franco Bruno Borghesi <franco@akyasociados.com.ar>
Cc: pgsql-sql@postgresql.org
Subject: Re: Group by and aggregates
Date: Fri, 5 Nov 2004 15:51:46 +0100
Message-ID: <20041105145146.GB47770@mich2.itxmarket.com> (raw)
In-Reply-To: <1099590115.1475.5.camel@taz.oficina>
References: <20041104165430.GD94770@mich2.itxmarket.com>
<1099590115.1475.5.camel@taz.oficina>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: mich@the-lab.org, franco@akyasociados.com.ar
Subject: Re: Group by and aggregates
In-Reply-To: <20041105145146.GB47770@mich2.itxmarket.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox