From: Tom Lane <tgl@sss.pgh.pa.us>
To: Stuart Rison <rison@biochemistry.ucl.ac.uk>
Cc: Moray McConnachie <moray.mcconnachie@computing-services.oxford.ac.uk>
Cc: pgsql-sql <pgsql-sql@postgreSQL.org>
Subject: Re: [SQL] DISTINCT & COUNT
Date: Fri, 26 Nov 1999 13:19:27 -0500
Message-ID: <16209.943640367@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.10.9911261746060.18438-100000@bsmlx17>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, rison@biochemistry.ucl.ac.uk, moray.mcconnachie@computing-services.oxford.ac.uk
Subject: Re: [SQL] DISTINCT & COUNT
In-Reply-To: <16209.943640367@sss.pgh.pa.us>
References: <Pine.LNX.4.10.9911261746060.18438-100000@bsmlx17> <16209.943640367@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox