counting distinct rows on more than one column

From: Dirk Lutzebaeck <lutzeb(at)aeccom(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: counting distinct rows on more than one column
Date: 2001-03-28 15:11:24
Message-ID: 15041.65308.150764.131312@ampato.core.aeccom.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-03-28 15:22:56 Re: pg_dump potential bug
Previous Message A James Lewis 2001-03-28 15:06:13 Re: Killing Postmaster