Re: sum of agreggates in one SELECT? - Mailing list pgsql-sql

From Louis-David Mitterrand
Subject Re: sum of agreggates in one SELECT?
Date
Msg-id 20000920084426.C1340@styx
Whole thread Raw
In response to Re: sum of agreggates in one SELECT?  (John McKown <joarmc@swbell.net>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Jie Liang
Date:
Subject: Re: [GENERAL] Foreign Keys Help Delete!
Next
From: Louis-David Mitterrand
Date:
Subject: Re: sum of agreggates in one SELECT?