Re: [GENERAL] Detecting change in event properties

2013-10-26 Thread Marc Mamin
>Marc Mamin-2 wrote >> I would misuse GUC variables for this. >> (using the functions current_setting and set_config) >> >> define a set get and switch fuction (I use operators for better >> readability) >> something like: >> >> select 'a' ==> 'foo' >> 'a' >> select 'b' <==> 'foo' >> 'a' >> select

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread David Johnston
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

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread David Johnston
Marc Mamin-2 wrote > I would misuse GUC variables for this. > (using the functions current_setting and set_config) > > define a set get and switch fuction (I use operators for better > readability) > something like: > > select 'a' ==> 'foo' > 'a' > select 'b' <==> 'foo' > 'a' > select <== 'foo' >

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread David Johnston
Robert James wrote > * Finding field x of the _previous_ row that meets a certain criteria > (which the current row may or may not meet) > ) This question could be phrased better. I provide an answer to my interpretation below. You'll need to play with the frame definition because I don't yet ha

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread Marc Mamin
>Von: pgsql-general-ow...@postgresql.org >[pgsql-general-ow...@postgresql.org]" im Auftrag von "Elliot >[yields.falseh...@gmail.com] >Gesendet: Freitag, 25. Oktober 2013 20:33 > >On 2013-10-25 13:35, Robert James wrote: >> On 10/25/13, Robert James wrote: >>> I have a table of (timed) events, a

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread Elliot
On 2013-10-25 13:35, Robert James wrote: On 10/25/13, Robert James wrote: I have a table of (timed) events, and I'm interested in marking events whose properties have changed from the previous event. I believe this can be done with window functions, but I'm not sure how. What window function

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread Pavel Stehule
Hello 2013/10/25 Robert James > On 10/25/13, Tom Lane wrote: > > Robert James writes: > >>> (To elaborate, I'm interested in: > >>> * Finding field x of the _previous_ row > >>> * Finding field x of the _next_ row > >>> * Finding field x of the _previous_ row that meets a certain criteria > >

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread Robert James
On 10/25/13, Tom Lane wrote: > Robert James writes: >>> (To elaborate, I'm interested in: >>> * Finding field x of the _previous_ row >>> * Finding field x of the _next_ row >>> * Finding field x of the _previous_ row that meets a certain criteria >>> (which the current row may or may not meet) >

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread Tom Lane
Robert James writes: >> (To elaborate, I'm interested in: >> * Finding field x of the _previous_ row >> * Finding field x of the _next_ row >> * Finding field x of the _previous_ row that meets a certain criteria >> (which the current row may or may not meet) >> ) > The first two are actually tri

Re: [GENERAL] Detecting change in event properties

2013-10-25 Thread Robert James
On 10/25/13, Robert James wrote: > I have a table of (timed) events, and I'm interested in marking events > whose properties have changed from the previous event. > > I believe this can be done with window functions, but I'm not sure > how. What window function can give me a field from the _previ

[GENERAL] Detecting change in event properties

2013-10-25 Thread Robert James
I have a table of (timed) events, and I'm interested in marking events whose properties have changed from the previous event. I believe this can be done with window functions, but I'm not sure how. What window function can give me a field from the _previous_ row? (To elaborate, I'm interested in