Received: from nsi.edu (amethea.nsi.edu [198.133.185.9]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA76325 for ; Tue, 18 Apr 2000 14:38:59 -0400 (EDT) (envelope-from reina@nsi.edu) Received: from nsi.edu (o21.nsi.edu [204.128.156.216]) by nsi.edu (8.9.1/8.9.1) with ESMTP id LAA23583; Tue, 18 Apr 2000 11:35:12 -0700 (PDT) Message-ID: <38FCACFC.55B12EB0@nsi.edu> Date: Tue, 18 Apr 2000 11:44:12 -0700 From: "G. Anthony Reina" Organization: The Neurosciences Institute X-Mailer: Mozilla 4.7 [en] (X11; U; IRIX 6.5 IP32) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane CC: "pgsql-sql@postgreSQL.org" Subject: Re: Counting distinct names References: <38FBBD02.4424CB34@nsi.edu> <17170.956028336@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200004/192 Tom Lane wrote: > "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 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