Stuart Rison <rison@biochemistry.ucl.ac.uk> writes:
> You can however do:
> SELECT DISTINCT c.cid
> FROM a,b,c
> WHERE a.aid=b.aid
> AND a.somefield=1 and a.otherfield=2
> AND c.cid=a.cid;
> and if your are using a interface (e.g. DBI::DBD::Pg) then you can get
> the number of tuples returned...
Or do the SELECT into a temp table, followed by fetching count(*) on the
temp table. Ugly, but avoids transferring what might be a lot of rows
to the frontend.
DISTINCT within aggregate functions is on the TODO list, but I don't
know when it will happen.
regards, tom lane