Re: FW: Count & Distinct
От | Nils Zonneveld |
---|---|
Тема | Re: FW: Count & Distinct |
Дата | |
Msg-id | 39A90F24.D0CC8ECB@casema.net обсуждение исходный текст |
Ответ на | FW: Count & Distinct ("anuj" <Anuj@in-control.de>) |
Список | pgsql-general |
anuj wrote: > > > >>> select count(distinct(row)) from table; > hi, > I have also tried but I am geting an error. > It's true that you get an error from trying to execute the query above; 'distinct' is not a function but a keyword, count() is a agregate function. Following this the correct notation for your query would be: select count(distinct <row>) from <table>; I tested this on postgreSQL 7.02 and it works. I tried this: NAW=# \d tmpTable Table "tmptable" Attribute | Type | Modifier -----------+-------------+---------- id | integer | name | varchar(25) | NAW=# select * from tmpTable; id | name ----+----------- 1 | Jansen 2 | Jansen 3 | Pietersen 4 | Pietersen (4 rows) NAW=# select count(name) from tmpTable; count ------- 4 (1 row) NAW=# select count(distinct name) from tmpTable; count ------- 2 (1 row) Success and kind regards, Nils Zonneveld -- "Misschien is niets geheel waar, en zelfs dat niet" Multatuli (Eduard Douwes Dekker) - Idee 1
В списке pgsql-general по дате отправления: