Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)
Дата
Msg-id 12390.1532466990@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Enhancement request: enable FIRST/LAST_value() also as a regularaggregate (not only as windowing function)  (matshyeq <matshyeq@gmail.com>)
Ответы Re: Enhancement request: enable FIRST/LAST_value() also as a regularaggregate (not only as windowing function)  (matshyeq <matshyeq@gmail.com>)
Список pgsql-hackers
matshyeq <matshyeq@gmail.com> writes:
> I'd like to throw here an enhancement proposal to discuss/consider.
> The FIRST/LAST_value()
> functions offer powerful lookup capabilities, ...
> but, given those values are repeating - why can't I simply use this
> functions as regular aggregates?
> Or can I? It doesn't seem to be possible while I find this use case
> actually more common than in windowing context…

The reason the SQL standard doesn't allow that usage, or similar ones
for other window functions, is that the function results are undefined
unless you specify a particular ordering of the inputs ... which is
exactly what the window syntax provides.

Yeah, in most cases there are other ways where you could get the same
result, but all of them require extra syntax too.  So you might as
well use window syntax and be standards-conforming.

> Anyway, Oracle is an example where both contexts are possible

Oracle is not exactly a shining example of either SQL spec compliance
or well-thought-out features ...

            regards, tom lane


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

Предыдущее
От: Daniel Gustafsson
Дата:
Сообщение: Re: [HACKERS] Optional message to user when terminating/cancellingbackend
Следующее
От: Vik Fearing
Дата:
Сообщение: Re: 11beta crash/assert caused by parameter type changes