Received: from sss.pgh.pa.us ([216.151.103.158]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3IIXvu49102 for ; Wed, 18 Apr 2001 14:33:57 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.3/8.11.3) with ESMTP id f3IIXFR12363; Wed, 18 Apr 2001 14:33:15 -0400 (EDT) To: "Josh Berkus" cc: Sara Cohen , pgsql-sql@postgresql.org Subject: Re: Subqueries in select clause In-reply-to: References: Comments: In-reply-to "Josh Berkus" message dated "Wed, 18 Apr 2001 08:44:07 -0700" Date: Wed, 18 Apr 2001 14:33:14 -0400 Message-ID: <12360.987618794@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200104/309 X-Sequence-Number: 2665 "Josh Berkus" writes: > Until you can upgrade, though, try this approach: > CREATE VIEW c_aggregate AS > SELECT sum(a) as sum_a, b FROM c GROUP BY b; > SELECT max(sum_a) FROM c_aggregate; Unfortunately that won't work in 7.0 --- grouped views have a lot of problems in that version, and one of the problems is that you can't do another level of aggregating on their results. Basically a view and a subselect are the same thing, so you can't get around the restrictions of one by using the other... 7.1 is what Sara needs. regards, tom lane