counting groups

From: Holger Klawitter <holger(at)klawitter(dot)de>
To: "pgsql-general(at)postgreSQL(dot)org" <pgsql-general(at)postgreSQL(dot)org>
Subject: counting groups
Date: 2000-10-24 11:11:14
Message-ID: 39F56E52.C65F5978@klawitter.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

is there any way to count groups in Postgres ? The following
(simplified) statement should return the number of attributes
which come up more than once.

SELECT count(distinct attr)
FROM table
WHERE condition
GROUP BY attr
HAVING count(*)>1

But it returns just the right number of 1's.
There must be a nicer way than selection INTO a temporary table
and counting from there ...

Regards,
Mit freundlichem Gruß,
Holger Klawitter
--
Holger Klawitter +49 (0)251 484 0637
holger(at)klawitter(dot)de http://www.klawitter.de/

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Holger Klawitter 2000-10-24 11:27:12 Re: counting groups
Previous Message Gilles DAROLD 2000-10-24 10:51:24 PL/Perl compilation error