Re: Detecting change in event properties

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Detecting change in event properties
Дата
Msg-id 6973.1382723382@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Detecting change in event properties  (Robert James <srobertjames@gmail.com>)
Ответы Re: Detecting change in event properties  (Robert James <srobertjames@gmail.com>)
Список pgsql-general
Robert James <srobertjames@gmail.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?

            regards, tom lane


В списке pgsql-general по дате отправления:

Предыдущее
От: Robert James
Дата:
Сообщение: Re: Detecting change in event properties
Следующее
От: David Johnston
Дата:
Сообщение: Re: Window functions and relational algebra