Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-30 Thread Lennin Caro
--- 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

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-30 Thread Jan Otto
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'

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-30 Thread r_musta
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 di

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-30 Thread r_musta
On Sep 29, 11:25 pm, [EMAIL PROTECTED] ("Scott Marlowe") wrote: > > 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 WH

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-29 Thread Klint Gore
Richard Broersma wrote: On Mon, Sep 29, 2008 at 4:36 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > SELECT count(distinct make), count(distinct color) from table WHERE >criteria<; Is this in the SQL spec? I didn't know Agg functions could do this? Yes. SQL92 6.5 ::= COUNT

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-29 Thread Richard Broersma
On Mon, Sep 29, 2008 at 4:36 PM, Tom Lane <[EMAIL PROTECTED]> wrote: > SELECT count(distinct make), count(distinct color) from table WHERE > >criteria<; Is this in the SQL spec? I didn't know Agg functions could do this? -- Regards, Richard Broersma Jr. Visit the Los Angeles PostgreSQL User

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-29 Thread Tom Lane
r_musta <[EMAIL PROTECTED]> 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 so

Re: [GENERAL] Counting unique rows as an aggregate.

2008-09-29 Thread Scott Marlowe
On Mon, Sep 29, 2008 at 12:12 PM, r_musta <[EMAIL PROTECTED]> wrote: > 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