Re: Subqueries in select clause

From: "Richard Huxton" <dev(at)archonet(dot)com>
To: "Sara Cohen" <sarina(at)cs(dot)huji(dot)ac(dot)il>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Subqueries in select clause
Date: 2001-04-18 14:17:38
Message-ID: 20010418141738.7A6ED2A3A7@mainbox.archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Sara Cohen <sarina(at)cs(dot)huji(dot)ac(dot)il> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2001-04-18 14:23:30 Re: Subqueries in select clause
Previous Message Lamar Owen 2001-04-18 14:14:13 Re: [GENERAL] Where are the 7.1 RPM's?