Re: Counting unique rows as an aggregate. - Mailing list pgsql-general

From Tom Lane
Subject Re: Counting unique rows as an aggregate.
Date
Msg-id 26009.1222731396@sss.pgh.pa.us
Whole thread Raw
In response to Counting unique rows as an aggregate.  (r_musta <zepolen@gmail.com>)
Responses Re: Counting unique rows as an aggregate.
List pgsql-general
r_musta <zepolen@gmail.com> writes:
> However, this is starting to become too slow (as there are about 10 of
> these queries), and therefore I need to write an aggregate function
> which lets me do:

> SELECT count_unique(make), count_unique(color) from table WHERE >criteria<;

I must be missing something, because I don't see why you couldn't do

SELECT count(distinct make), count(distinct color) from table WHERE >criteria<;

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: database question
Next
From: Mike Diehl
Date:
Subject: Re: Can't cast from char to integer...