On Sun, 2015-11-08 at 17:50 -0500, Tom Lane wrote:
> Oliver Elphick <olly(at)lfix(dot)co(dot)uk> writes:
> > I tried to do this:
> > SELECT p.company, p.start, p.yearend, p.idnum,
> > s.pdno, s.pdend,
> > CASE WHEN nth_value(s.pdend,(row_number() OVER w)::INTEGER -1) OVER w IS NULL
> > THEN p.start
> > ELSE nth_value(s.pdend,(row_number() OVER w)::INTEGER -1) + '1 day'::INTERVAL
>
> Um, don't you just want lead() or lag()?
>
> regards, tom lane
So I do! Thanks.