| 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 |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| 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.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2000-04-18 03:25:36 | Re: Counting distinct names |
| Previous Message | G. Anthony Reina | 2000-04-18 01:40:18 | Counting distinct names |