| From: | "Brett W(dot) McCoy" <bmccoy(at)lan2wan(dot)com> |
|---|---|
| To: | Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il> |
| Cc: | Aaron Holtz <aholtz(at)bright(dot)net>, pgsql-general(at)postgreSQL(dot)org |
| Subject: | Re: [GENERAL] Any ideas why this doesn't work or how to rewrite it? |
| Date: | 1999-04-29 18:04:45 |
| Message-ID: | Pine.BSI.3.91.990429140136.6326F-100000@access1.lan2wan.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
On Thu, 29 Apr 1999, Herouth Maoz wrote:
> At 18:50 +0300 on 28/04/1999, Aaron Holtz wrote:
>
>
> > 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.
>
> Valid it is, but not yet supported in PostgreSQL.
>
> An (ugly) workaround would be something along the lines of:
>
> SELECT count(customer_username)
> FROM customerdata c1
> WHERE int( oid ) = (
> SELECT min( int( c2.oid ) )
> FROM customerdata c2
> WHERE c1.customer_username = c2.customer_username
> );
I think, Aaron, you could get a count of distinct customer names like this:
SELECT DISTINCT customer_username, COUNT(*) FROM customerdata
GROUP BY customer_username;
This will give you 2 columns, one with the distinct customer_usernames
and the second with the count of each. The GROUP BY caluse is important
here. This looks like what you wanted in your original query.
Brett W. McCoy
http://www.lan2wan.com/~bmccoy
-----------------------------------------------------------------------
Schapiro's Explanation:
The grass is always greener on the other side -- but that's
because they use more manure.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | The Hermit Hacker | 1999-04-29 18:50:46 | RE: [GENERAL] LIMIT QUESTION |
| Previous Message | Adriaan Joubert | 1999-04-29 18:02:16 | Timing queries |