Elliot wrote > Maybe a custom aggregate that takes the last item in a set? > > CREATE OR REPLACE FUNCTION public.last_agg ( anyelement, anyelement ) > RETURNS anyelement LANGUAGE sql IMMUTABLE STRICT AS $$ > SELECT $2; > $$; > > CREATE AGGREGATE public.last ( > sfunc = public.last_agg, > basetype = anyelement, > stype = anyelement > ); Conceptually similar to my array_last_nonnull(array_agg(...)) methodology and the GUC methodology but has the advantage of saving minimal state (compared to the array_agg()) and not abusing GUC for storage of the single-value state. The example would need the same alteration to the frame clause but otherwise would appear to work in the manner presumed by the OP's original question. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Detecting-change-in-event-properties-tp5775959p5775977.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general