Re: Enhancement request: enable FIRST/LAST_value() also as a regularaggregate (not only as windowing function) - Mailing list pgsql-hackers

From Vik Fearing
Subject Re: Enhancement request: enable FIRST/LAST_value() also as a regularaggregate (not only as windowing function)
Date
Msg-id 5503452e-bd22-8ea5-d874-32c3b05250d7@2ndquadrant.com
Whole thread Raw
In response to Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 26/07/18 20:31, Tom Lane wrote:
> matshyeq <matshyeq@gmail.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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Enhancement request: enable FIRST/LAST_value() also as a regular aggregate (not only as windowing function)
Next
From: Robert Haas
Date:
Subject: Re: 11beta crash/assert caused by parameter type changes