Received: from www-uk-05.digiserve.com ([195.97.231.11]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3IEOfu77039 for ; Wed, 18 Apr 2001 10:24:41 -0400 (EDT) (envelope-from dev@archonet.com) Received: from mainbox.archonet.com (mwynhau.demon.co.uk [193.237.186.96]) by www-uk-05.digiserve.com (8.9.1/8.9.1) with ESMTP id PAA20920; Wed, 18 Apr 2001 15:21:59 +0100 (BST) Received: from archonet.com (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with SMTP id 7A6ED2A3A7; Wed, 18 Apr 2001 15:17:38 +0100 (BST) Date: Wed, 18 Apr 2001 14:17:38 -0000 To: "Sara Cohen" Subject: Re: Subqueries in select clause From: "Richard Huxton" X-Mailer: TWIG 2.6.2 In-Reply-To: Cc: Message-Id: <20010418141738.7A6ED2A3A7@mainbox.archonet.com> X-Archive-Number: 200104/304 X-Sequence-Number: 2660 Sara Cohen said: > Hi, > > I am attempting to use subqueries in the select clause of a query > and am encountering difficulties. > > The Problem: > ------------ > > I would like to use a subquery that returns one column, but more than one > tuple. The result of this subquery is then used in an aggregate function. > Using Oracle, I could get by this problem with: > > select max(d) from ((select count(b) as d from c group by a)); > > However, my version of postgres doesn't support subqueries in the from > clause. In 7.1 at least you can do it if you alias the sub-query: select max(d) from (select count(b) as d from c group by a) as calias; Sorry, I don't know if 7.0.2 handles this (but you probably want to upgrade anyway - I seem to remember some problems with 7.0.2) HTH - Richard Huxton