| От | Tom Lane |
|---|---|
| Тема | Re: Distinct on a non-sort column |
| Дата | |
| Msg-id | 17666.1320534691@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Distinct on a non-sort column (Cstdenis <lists@on-track.ca>) |
| Ответы |
Re: Distinct on a non-sort column
|
| Список | pgsql-general |
Cstdenis <lists@on-track.ca> writes:
> If I understand that you are proposing as
> select * from
> (select distinct on (user_id) * from stories as s order
> by user_id) as foo
> order by date_submitted desc limit 10;
No, you always need to sort by *more* columns than are listed in
DISTINCT ON. That's what determines which row is picked in each
DISTINCT group. Read the SELECT reference page's example of how
to use DISTINCT ON.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера