Skip site navigation (1) Skip section navigation (2)

Re: Counting distinct names

From: "Brett W(dot) McCoy" <bmccoy(at)chapelperilous(dot)net>
To: "G(dot) Anthony Reina" <reina(at)nsi(dot)edu>
Cc: "pgsql-sql(at)postgreSQL(dot)org" <pgsql-sql(at)postgreSQL(dot)org>
Subject: Re: Counting distinct names
Date: 2000-04-18 02:16:09
Message-ID: Pine.LNX.4.10.10004172202030.6329-100000@chapelperilous.net (view raw or flat)
Thread:
Lists: pgsql-sql
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.


In response to

pgsql-sql by date

Next:From: Tom LaneDate: 2000-04-18 03:25:36
Subject: Re: Counting distinct names
Previous:From: G. Anthony ReinaDate: 2000-04-18 01:40:18
Subject: Counting distinct names

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group