Re: sorting problem with distinct on()

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: sorting problem with distinct on()
Дата
Msg-id 3585863.1683296778@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: sorting problem with distinct on()  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Fri, May 5, 2023 at 6:55 AM Sky Lendar <skylendar@gmail.com> wrote:
>> Notice that 12 is missing in the list.

> Since your DISTINCT ON *subquery* doesn't specify an ordering which of
> those two are chosen as the representative record for M31 is
> non-determinstic.

> If you want to ensure the lowest valued nb is chosen you need to sort the
> *subquery*.

The "weather_reports" example here might help clarify this for you:

https://www.postgresql.org/docs/current/sql-select.html

            regards, tom lane



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

Предыдущее
От: Sky Lendar
Дата:
Сообщение: Re: sorting problem with distinct on()
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: SSL Enablement in Postgres via Client App like PG-ADMIN-4, Java.