Received: from styx.apartia.int (postfix@r34m39.cybercable.tm.fr [195.132.34.39]) by hub.org (8.10.1/8.10.1) with ESMTP id e8K6igs52945 for ; Wed, 20 Sep 2000 02:44:43 -0400 (EDT) Received: by styx.apartia.int (Postfix, from userid 1000) id 624EB4D78; Wed, 20 Sep 2000 08:44:26 +0200 (CEST) Date: Wed, 20 Sep 2000 08:44:26 +0200 From: Louis-David Mitterrand To: John McKown Cc: pgsql-sql@postgresql.org Subject: Re: sum of agreggates in one SELECT? Message-ID: <20000920084426.C1340@styx> Reply-To: ldm@apartia.ch Mail-Followup-To: John McKown , pgsql-sql@postgresql.org References: <20000919125859.A2802@styx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from joarmc@swbell.net on Tue, Sep 19, 2000 at 01:17:01PM -0500 X-Archive-Number: 200009/144 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