Re: Help with simple query

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Help with simple query
Дата
Msg-id 2596.1135816997@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Help with simple query  (Collin Peters <cadiolis@gmail.com>)
Список pgsql-sql
Collin Peters <cadiolis@gmail.com> writes:
> Is there a nice simple query I can run that will return me a list of
> all the *latest* notes for all users (users can have many notes in the
> table)?

You can use SELECT DISTINCT ON for that, if you don't mind using a
Postgres-only feature.  See the "weather reports" example in the SELECT
reference page.

If you want to stick to portable SQL, you can still do it, but it's
pretty ugly and slow.  Look in the list archives for previous
discussions.
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Collin Peters
Дата:
Сообщение: Help with simple query
Следующее
От: Frank Bax
Дата:
Сообщение: Re: Help with simple query