| От | Tom Lane |
|---|---|
| Тема | Re: Getting the latest unique items |
| Дата | |
| Msg-id | 4081.1039677209@sss.pgh.pa.us обсуждение |
| Ответ на | Re: Getting the latest unique items ("A.M." <agentm@cmu.edu>) |
| Список | pgsql-sql |
"A.M." <agentm@cmu.edu> writes: > When I try to run the following query: > select distinct on(student_gradedmaterial.id) ... ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > ... order by submittime desc; ^^^^^^^^^^^^^^^^^^^ > I get the following error: > ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY > expressions Indeed. You might benefit from reading the DISTINCT ON usage example given in the SELECT reference page, http://www.ca.postgresql.org/users-lounge/docs/7.3/postgres/sql-select.html (see under "Description"). Basically, DISTINCT ON is *only* useful when designed hand-in-hand with an ORDER BY ... regards, tom lane
В списке pgsql-sql по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера