Re: Counting distinct names - Mailing list pgsql-sql

From G. Anthony Reina
Subject Re: Counting distinct names
Date
Msg-id 38FCACFC.55B12EB0@nsi.edu
Whole thread Raw
In response to Counting distinct names  ("G. Anthony Reina" <reina@nsi.edu>)
Responses Re: Counting distinct names  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
Tom Lane wrote:

> "G. Anthony Reina" <reina@nsi.edu> writes:
> > I'd like to find out how many times a unique 'subject_name' is in the
> > table. My SQL book says that I should be able to do this:
> > select COUNT(DISTINCT subject_name) from table1;
> > However, the psql program is giving me an "ERROR:  parser: parse error
> > at or near "distinct"".
>
> 6.5 doesn't have aggregate(DISTINCT ...).  7.0 does, though.
>
> If you don't want to upgrade right now, you could do something like
>
> SELECT DISTINCT subject_name INTO temp_table FROM table1;
> SELECT count(*) FROM temp_table;
> DROP TABLE temp_table;
>
>                         regards, tom lane

Thanks Tom. I'll eventually upgrade, but still am a little wary considering
how many messages hackers continues to get on beta5. Perhaps, when 7.1 is
out I'll feel a little more secure about the upgrade.

-Tony




pgsql-sql by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Outer joins
Next
From: "Angela Harkins"
Date:
Subject: sql database synchronization