From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | matshyeq <matshyeq(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function) |
Date: | 2018-07-24 21:16:30 |
Message-ID: | 12390.1532466990@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
matshyeq <matshyeq(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Vik Fearing | 2018-07-24 21:34:15 | Re: 11beta crash/assert caused by parameter type changes |
Previous Message | Daniel Gustafsson | 2018-07-24 20:57:09 | Re: [HACKERS] Optional message to user when terminating/cancelling backend |