Received: from chapelperilous.net (chapelperilous.net [216.254.44.199]) by hub.org (8.9.3/8.9.3) with ESMTP id WAA72917 for ; Mon, 17 Apr 2000 22:08:43 -0400 (EDT) (envelope-from bmccoy@chapelperilous.net) Received: from localhost (bmccoy@localhost) by chapelperilous.net (8.9.3/8.9.3) with ESMTP id WAA06454; Mon, 17 Apr 2000 22:16:09 -0400 Date: Mon, 17 Apr 2000 22:16:09 -0400 (EDT) From: "Brett W. McCoy" To: "G. Anthony Reina" cc: "pgsql-sql@postgreSQL.org" Subject: Re: Counting distinct names In-Reply-To: <38FBBD02.4424CB34@nsi.edu> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200004/176 On Mon, 17 Apr 2000, G. Anthony Reina wrote: > Let's say I have a table: > > table1 > ===== > > subject_name text > subject_age int4 > test_trial int4 > test_score int4 > > > 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; SELECT DISTINCT(subject_name), COUNT(subject_name) FROM table1 GROUP BY subject_name ; Brett W. McCoy http://www.chapelperilous.net --------------------------------------------------------------------------- Anything that is good and useful is made of chocolate.