--- On Tue, 9/30/08, r_musta <[EMAIL PROTECTED]> wrote:

> From: r_musta <[EMAIL PROTECTED]>
> Subject: Re: [GENERAL] Counting unique rows as an aggregate.
> To: pgsql-general@postgresql.org
> Date: Tuesday, September 30, 2008, 6:55 AM
> On Sep 30, 2:36 am, [EMAIL PROTECTED] (Tom Lane) wrote:
> > > 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<;
> 
> I didn't explain well, I want the count of each
> distinct value in a
> column, eg, if the color column has 50 rows,
> 20x'red', 10x'green',
> 20x'blue' - it will give me those results.
> 
> SELECT count(distinct color) would return 3 - which is the
> count of
> distinct values, which is not what I want.
> 

SELECT count(color),color from table group by color


      


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to