From: Louis-David Mitterrand <cunctator@apartia.ch>
To: John McKown <joarmc@swbell.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: sum of agreggates in one SELECT?
Date: Wed, 20 Sep 2000 08:44:26 +0200
Message-ID: <20000920084426.C1340@styx> (raw)
In-Reply-To: <Pine.LNX.4.21.0009191308300.20327-100000@linux2.johnmckown.net>
References: <20000919125859.A2802@styx>
<Pine.LNX.4.21.0009191308300.20327-100000@linux2.johnmckown.net>
On Tue, Sep 19, 2000 at 01:17:01PM -0500, John McKown wrote:
> Well, it's not a single SELECT, but why not use something like:
>
> SELECT MAX(b.lot) AS quanity, max(p.price) AS price, p.login
> INTO TEMPORARY TABLE temp1
> FROM bid b, person p
> WHERE b.auction_id=84 AND p.id=b.person_id
> GROUP BY p.login
> ORDER BY max(price);
>
> SELECT SUM(quanity) from temp1;
>
> If you need the output from the original SELECT then you can print it by
> simply doing:
>
> SELECT * FROM temp1;
>
> Hope this is of some use to you,
Very useful, as it demonstrates that (as in perl) there is sometimes
more than one way to do it. Your solution works fine, and along the way
I learned to use temporary tables.
Thanks a lot for your input, cheers,
--
Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org
How's my posting? Call 1-800-DEV-NULL
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: cunctator@apartia.ch, joarmc@swbell.net
Subject: Re: sum of agreggates in one SELECT?
In-Reply-To: <20000920084426.C1340@styx>
References: <20000919125859.A2802@styx> <Pine.LNX.4.21.0009191308300.20327-100000@linux2.johnmckown.net> <20000920084426.C1340@styx>
* 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