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

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, robertmhaas(at)gmail(dot)com
Subject: Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)
Date: 2018-07-26 18:31:26
Message-ID: 29473.1532629886@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

matshyeq <matshyeq(at)gmail(dot)com> writes:
> Can I make custom aggregate function that accepts WITHIN GROUP syntax?

It's possible, but it would have to be written in C, I think; see
src/backend/utils/adt/orderedsetaggs.c for prototype code. You'll
find it a lot easier to write a plain aggregate function and control
its input ordering with "last(foo order by foo)".

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2018-07-26 18:40:14 Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)
Previous Message matshyeq 2018-07-26 18:06:36 Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)