Re: sum of agreggates in one SELECT?

From: Louis-David Mitterrand <cunctator(at)apartia(dot)ch>
To: John McKown <joarmc(at)swbell(dot)net>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sum of agreggates in one SELECT?
Date: 2000-09-20 06:44:26
Message-ID: 20000920084426.C1340@styx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)apartia(dot)org - http://www.apartia.org

How's my posting? Call 1-800-DEV-NULL

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Louis-David Mitterrand 2000-09-20 13:23:04 no ORDER BY in subselects?
Previous Message Jie Liang 2000-09-20 01:19:43 Re: [GENERAL] Foreign Keys Help Delete!