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.