Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154] (may be forged)) by hub.org (8.10.1/8.10.1) with ESMTP id e8JHT4s17401 for ; Tue, 19 Sep 2000 13:29:04 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.0/8.11.0) with ESMTP id e8JHRmB07128; Tue, 19 Sep 2000 13:27:48 -0400 (EDT) To: ldm@apartia.ch cc: pgsql-sql@postgresql.org Subject: Re: sum of agreggates in one SELECT? In-reply-to: <20000919125859.A2802@styx> References: <20000919125859.A2802@styx> Comments: In-reply-to Louis-David Mitterrand message dated "Tue, 19 Sep 2000 12:58:59 +0200" Date: Tue, 19 Sep 2000 13:27:48 -0400 Message-ID: <7125.969384468@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200009/135 Louis-David Mitterrand writes: > Now I would like to sum() all results from the quantity column and > return it with one SELECT statement. Is that possible? You can't have aggregates of aggregates in a single SELECT structure; that's just not in the SQL execution model. The way around this is to write multiple levels of SELECT, using either selection from a grouped/aggregated view or subselect-in-FROM. Unfortunately Postgres doesn't have either of those features --- yet. They might be in 7.1 if I spend less time answering email and more time coding... regards, tom lane