From: G. Anthony Reina <reina@nsi.edu>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgreSQL.org <pgsql-sql@postgreSQL.org>
Subject: Re: Counting distinct names
Date: Tue, 18 Apr 2000 11:44:12 -0700
Message-ID: <38FCACFC.55B12EB0@nsi.edu> (raw)
References: <38FBBD02.4424CB34@nsi.edu>
<17170.956028336@sss.pgh.pa.us>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: reina@nsi.edu, tgl@sss.pgh.pa.us
Subject: Re: Counting distinct names
In-Reply-To: <38FCACFC.55B12EB0@nsi.edu>
References: <38FBBD02.4424CB34@nsi.edu> <17170.956028336@sss.pgh.pa.us> <38FCACFC.55B12EB0@nsi.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox