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 e8K6wps57818 for ; Wed, 20 Sep 2000 02:58:51 -0400 (EDT) Received: by styx.apartia.int (Postfix, from userid 1000) id CAB6B5AEE; Tue, 19 Sep 2000 22:06:57 +0200 (CEST) Date: Tue, 19 Sep 2000 22:06:57 +0200 From: Louis-David Mitterrand To: Josh Berkus Cc: sqllist Subject: Re: sum of agreggates in one SELECT? Message-ID: <20000919220657.E557@styx> Reply-To: ldm@apartia.ch Mail-Followup-To: Josh Berkus , sqllist References: <20000919125859.A2802@styx> <7125.969384468@sss.pgh.pa.us> <39C7AB0E.FA901CF8@agliodbs.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <39C7AB0E.FA901CF8@agliodbs.com>; from josh@agliodbs.com on Tue, Sep 19, 2000 at 11:06:06AM -0700 X-Archive-Number: 200009/145 On Tue, Sep 19, 2000 at 11:06:06AM -0700, Josh Berkus wrote: > > Unfortunately, Louis-David, I don't see any way around subselects in the > FROM clause as Tom mentions, which are not currently supported. I'd > suggest using a Function to create a temporary table or view and > summarizing from that. I did create a pl/pgsql function in the end, to compute my total: FOR bid IN SELECT max(b.lot) AS price FROM bid b WHERE b.auction_id = $1 GROUP BY b.person_id LOOP i := i + bid.price; END LOOP; RETURN i; Thanks for your input, -- Louis-David Mitterrand - ldm@apartia.org - http://www.apartia.org "Faith strikes me as intellectual laziness." -- Robert A. Heinlein