I'm using the lag()
function to find the value that occurred previously in the same field for any particular value.
Is there a function to find the one next/after the field value?
example data:
id desc
1 line1
1 line2
1 line 3
2 line 1
2 line 2
2 line 3
expected result:
current lg_desc next
line 2 line1 line 3
line 2 line1 line 3
the query i have so far is:
select Desc as current,
lag(Description)
over (partition by ID order by TimestampUTC) as lg_desc
from #temp1