Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id XAA64999 for ; Mon, 17 Apr 2000 23:25:49 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id XAA17173; Mon, 17 Apr 2000 23:25:36 -0400 (EDT) To: "G. Anthony Reina" cc: "pgsql-sql@postgreSQL.org" Subject: Re: Counting distinct names In-reply-to: <38FBBD02.4424CB34@nsi.edu> References: <38FBBD02.4424CB34@nsi.edu> Comments: In-reply-to "G. Anthony Reina" message dated "Mon, 17 Apr 2000 18:40:18 -0700" Date: Mon, 17 Apr 2000 23:25:36 -0400 Message-ID: <17170.956028336@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200004/177 "G. Anthony Reina" 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