From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Steve Midgley <science(at)misuse(dot)org> |
Cc: | Mohamed DIA <macdia2002(at)gmail(dot)com>, postgres list <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Issues with lag command |
Date: | 2017-07-28 19:29:06 |
Message-ID: | CAKFQuwYo0xNPRFpAoyd3r9wkuhT69oGfKY+c_6VEXZguYwdpkg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Fri, Jul 28, 2017 at 12:21 PM, Steve Midgley <science(at)misuse(dot)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.
From | Date | Subject | |
---|---|---|---|
Next Message | Igor Neyman | 2017-07-28 19:53:15 | Re: Issues with lag command |
Previous Message | Steve Midgley | 2017-07-28 19:21:49 | Re: Issues with lag command |