Sara Cohen <sarina@cs.huji.ac.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