Re: (un)grouping question
| От | Reece Hart |
|---|---|
| Тема | Re: (un)grouping question |
| Дата | |
| Msg-id | 1200941930.7144.24.camel@snafu обсуждение исходный текст |
| Ответ на | (un)grouping question ("Rhys Stewart" <rhys.stewart@gmail.com>) |
| Список | pgsql-general |
On Mon, 2008-01-21 at 12:36 -0500, Rhys Stewart wrote:
There's certainly no need for a random number hack. Instead, use a query like 'select distinct on (somevalue) * from mytable;' .
Although DISTINCT is standard, the DISTINCT ON (cols) variant is a PostgreSQL-ism.
See http://www.postgresql.org/docs/8.2/static/queries-select-lists.html#QUERIES-DISTINCT .
-Reece, your heterographic brother
uid|somevalue
--------------------
1|11
2|44
3|31
4|44
5|71
6|33
7|33
8|44
9|14
would like to remove the duplicate values in the column somevalue. doing this by just adding a random number is perfectly fine, however i want to retain at least one of the original values of somevalue. Any ideas how to do this in in a query?
There's certainly no need for a random number hack. Instead, use a query like 'select distinct on (somevalue) * from mytable;' .
Although DISTINCT is standard, the DISTINCT ON (cols) variant is a PostgreSQL-ism.
See http://www.postgresql.org/docs/8.2/static/queries-select-lists.html#QUERIES-DISTINCT .
-Reece, your heterographic brother
-- Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0 |
В списке pgsql-general по дате отправления: