Re: [SQL] Issues with lag command

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: [SQL] Issues with lag command
Дата
Msg-id CAKFQuwYo0xNPRFpAoyd3r9wkuhT69oGfKY+c_6VEXZguYwdpkg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [SQL] Issues with lag command  (Steve Midgley <science@misuse.org>)
Список pgsql-sql
On Fri, Jul 28, 2017 at 12:21 PM, Steve Midgley <science@misuse.org> wrote:

The general logic is that anytime we find a record with a time_id null, we would like to update it with the previous time_id that is not null.
I use the LAG function and the below code


​Lag can be made to work but only if you know that maximum lag that guarantees a non-null value is present.  If you cannot pick a reasonable number then you should write a custom aggregate function.  I believe I've seen posts (probably to -general) detailing this and you might find it in blog posts or the like as well.  I'm unable to provide a working example right now.

David J.

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

Предыдущее
От: Steve Midgley
Дата:
Сообщение: Re: [SQL] Issues with lag command
Следующее
От: Igor Neyman
Дата:
Сообщение: Re: [SQL] Issues with lag command