Re: [GENERAL] Any ideas why this doesn't work or how to rewrite it?

From: Oleg Broytmann <phd(at)sun(dot)med(dot)ru>
To: Aaron Holtz <aholtz(at)bright(dot)net>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Any ideas why this doesn't work or how to rewrite it?
Date: 1999-04-28 16:00:04
Message-ID: Pine.SOL2.3.96.SK.990428195739.25567A-100000@sun.med.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, 28 Apr 1999, Aaron Holtz wrote:
> This seems like a simple SQL command, but I'm getting errors.
> Running 6.5.0 under RedHat 5.2:
>
> db=> select count(distinct customer_username) from customerdata;
> ERROR: parser: parse error at or near "distinct"
>
> How do you get a count of distinct data output via postgres? I can always
> just count the number of tuples returned but this seemed to be a valid
> query.

In SQL, it is just pretty valid query. But Postgres does not implement
SELECT COUNT(DISTINCT).

Do instead
SELECT DISTINCT(customer_username) FROM customerdata;
and count it in your program.

> --------------------------------------------------------------------------
> Aaron Holtz
> ComNet Inc.
> UNIX Systems Specialist
> Email: aholtz(at)bright(dot)net
> "It's not broken, it just lacks duct tape."
> --------------------------------------------------------------------------

Oleg.
----
Oleg Broytmann http://members.xoom.com/phd2/ phd2(at)earthling(dot)net
Programmers don't die, they just GOSUB without RETURN.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Lo 1999-04-28 16:05:18 Re: [GENERAL] DBI driver for Postgres?
Previous Message Wim Ceulemans 1999-04-28 15:58:35 Search engine with PostgreSQL