Re: [GENERAL] Any ideas why this doesn't work or how to rewrite it?
От | Brett W. McCoy |
---|---|
Тема | Re: [GENERAL] Any ideas why this doesn't work or how to rewrite it? |
Дата | |
Msg-id | Pine.BSI.3.91.990429140136.6326F-100000@access1.lan2wan.com обсуждение исходный текст |
Ответ на | Re: [GENERAL] Any ideas why this doesn't work or how to rewrite it? (Herouth Maoz <herouth@oumail.openu.ac.il>) |
Ответы |
Re: [GENERAL] Any ideas why this doesn't work or how to rewrite
it?
|
Список | 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.
В списке pgsql-general по дате отправления: