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

From: Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, 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:40:14
Message-ID: 5503452e-bd22-8ea5-d874-32c3b05250d7@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 26/07/18 20:31, Tom Lane wrote:
> 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)".

We have examples on the wiki.
https://wiki.postgresql.org/wiki/First/last_(aggregate)
--
Vik Fearing +33 6 46 75 15 36
http://2ndQuadrant.fr PostgreSQL : Expertise, Formation et Support

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2018-07-26 19:14:53 Re: 11beta crash/assert caused by parameter type changes
Previous Message Tom Lane 2018-07-26 18:31:26 Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)