Re: Idea: PostgreSQL equivalent to Oracle's KEEP clause

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Idea: PostgreSQL equivalent to Oracle's KEEP clause
Дата
Msg-id CAApHDvouQomvLrd+0hAMX4VrnvszjnqeJ7j4or+nQ7MsMnjoeg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Idea: PostgreSQL equivalent to Oracle's KEEP clause  (Alban Hertroys <haramrae@gmail.com>)
Список pgsql-general
On Tue, 14 Mar 2023 at 21:01, Alban Hertroys <haramrae@gmail.com> wrote:
> > On 7 Mar 2023, at 4:11, David G. Johnston <david.g.johnston@gmail.com> wrote:
> > TOP(city, ROW(population, land_area)) ?
>
> What should be the expected behaviour on a tie though?

Undefined.  Same as having an ORDER BY on a column that's not unique.
The sort implementation effectively defines the order.  David did
specify the ROW() idea as a means to add additional columns so that
the tiebreak could be done with some other deciding factor.

> Should the result be just the first of the maximums (or minimums) through some selection criterium (such as their
alphabeticalorder), should that give each of the tied results, or should there be a means to define that behaviour?
 

It's an aggregate function. There's only 1 return value per group. If
you didn't want that you'd likely want to use a window function such
as rank() and add an outer query and filter out anything that's not
rank 1.

David



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

Предыдущее
От: Thorsten Glaser
Дата:
Сообщение: Re: Uppercase version of ß desired
Следующее
От: David Rowley
Дата:
Сообщение: Re: Idea: PostgreSQL equivalent to Oracle's KEEP clause