From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Robert James <srobertjames(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Postgres General <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Detecting change in event properties |
Date: | 2013-10-25 18:13:43 |
Message-ID: | CAFj8pRB+Kjt0Z5+ea=gx0-_rC86nHjKFM=29WMPjWNxJtzjH4g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello
2013/10/25 Robert James <srobertjames(at)gmail(dot)com>
> On 10/25/13, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> > Robert James <srobertjames(at)gmail(dot)com> 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 trivial - lag(field_x) over (order by [same
> >> order as query]) and lead(...).
> >
> > Right.
> >
> >> But the last one seems ellusive - How can I find the value of field x
> >> on the previous row WHERE a criteria is met? Is it possible to do this
> >> at all with a window function?
> >
> > I don't see any way to achieve that with any of the built-in window
> > functions, but I believe it could be done by a custom window function.
> > Are you up for some C coding?
>
> Hmmm... certainly nothing I would trust on a production db.
>
> Is there a way to do it without C not using window functions? Perhaps
> with some type of JOIN?
>
you can write a table function with inner loop cycle over cursor
Regards
Pavel
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
From | Date | Subject | |
---|---|---|---|
Next Message | Elliot | 2013-10-25 18:33:34 | Re: Detecting change in event properties |
Previous Message | Robert James | 2013-10-25 18:10:43 | Re: Detecting change in event properties |