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

Counting distinct names

From: "G(dot) Anthony Reina" <reina(at)nsi(dot)edu>
To: "pgsql-sql(at)postgreSQL(dot)org" <pgsql-sql(at)postgreSQL(dot)org>
Subject: Counting distinct names
Date: 2000-04-18 01:40:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Let's say I have a table:


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;

However, the psql program is giving me an "ERROR:  parser: parse error
at or near "distinct"".

Is there another way to do this (or a problem with my query)?

-Tony Reina

Using [PostgreSQL 6.5.1 on i686-pc-linux-gnu, compiled by gcc


pgsql-sql by date

Next:From: Brett W. McCoyDate: 2000-04-18 02:16:09
Subject: Re: Counting distinct names
Previous:From: Titus BrownDate: 2000-04-18 00:17:48
Subject: Re: Connecting website with SQL-database.....

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