From: Tom Lane <tgl@sss.pgh.pa.us>
To: G. Anthony Reina <reina@nsi.edu>
Cc: pgsql-sql@postgreSQL.org <pgsql-sql@postgreSQL.org>
Subject: Re: Counting distinct names
Date: Mon, 17 Apr 2000 23:25:36 -0400
Message-ID: <17170.956028336@sss.pgh.pa.us> (raw)
In-Reply-To: <38FBBD02.4424CB34@nsi.edu>
References: <38FBBD02.4424CB34@nsi.edu>
"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
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: tgl@sss.pgh.pa.us, reina@nsi.edu
Subject: Re: Counting distinct names
In-Reply-To: <17170.956028336@sss.pgh.pa.us>
References: <38FBBD02.4424CB34@nsi.edu> <17170.956028336@sss.pgh.pa.us>
* 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