From: Michael Ansley <Michael.Ansley@intec-telecom-systems.com>
To: 'Dirk Lutzebaeck' <lutzeb@aeccom.com>
Cc: pgsql-sql@postgresql.org
Subject: RE: counting distinct rows on more than one column
Date: Wed, 28 Mar 2001 16:58:13 +0100
Message-ID: <7F124BC48D56D411812500D0B747251480F4F1@FILESERVER002> (raw)
SELECT count(*) FROM (SELECT DISTINCT a, b FROM t) AS t2;
should give you what you want.
MikeA
>> -----Original Message-----
>> From: Dirk Lutzebaeck [mailto:lutzeb@aeccom.com]
>> Sent: 28 March 2001 16:11
>> To: pgsql-sql@postgresql.org
>> Subject: [SQL] counting distinct rows on more than one column
>>
>>
>>
>> Hi,
>>
>> on 7.0.3 want to COUNT
>>
>> SELECT DISTINCT a,b FROM t;
>>
>> I can't find a solution because any combination with
>> count with more than one column gives syntax errors.
>>
>> One solution would be to set a view:
>>
>> CREATE VIEW v AS SELECT DISTINCT a,b FROM t;
>>
>> and then
>>
>> SELECT count(a) FROM v
>>
>> but views don't support distinct in v7.0.3
>>
>> Ok I could use a temporary table but my select distinct tends to give
>> large results.
>>
>> Any clues?
>>
>> Dirk
>>
>>
>>
>> ---------------------------(end of
>> broadcast)---------------------------
>> TIP 1: subscribe and unsubscribe commands go to
>> majordomo@postgresql.org
>>
_________________________________________________________________________
This e-mail and any attachments are confidential and may also be privileged and/or copyright
material of Intec Telecom Systems PLC (or its affiliated companies). If you are not an
intended or authorised recipient of this e-mail or have received it in error, please delete
it immediately and notify the sender by e-mail. In such a case, reading, reproducing,
printing or further dissemination of this e-mail is strictly prohibited and may be unlawful.
Intec Telecom Systems PLC. does not represent or warrant that an attachment hereto is free
from computer viruses or other defects. The opinions expressed in this e-mail and any
attachments may be those of the author and are not necessarily those of Intec Telecom
Systems PLC.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
__________________________________________________________________________
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: Michael.Ansley@intec-telecom-systems.com, lutzeb@aeccom.com
Subject: Re: counting distinct rows on more than one column
In-Reply-To: <7F124BC48D56D411812500D0B747251480F4F1@FILESERVER002>
References: <7F124BC48D56D411812500D0B747251480F4F1@FILESERVER002>
* 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