On Sun, 2015-11-08 at 17:50 -0500, Tom Lane wrote: > Oliver Elphick <olly@xxxxxxxxxx> 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. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general