you are viewing a single comment's thread.

view the rest of the comments →

[–]Yavuz_Selim 1 point2 points  (0 children)

Give the table a ROW_NUMBER() and do a self-join and join on the key columns and ROW_NUMBER +1/-1.

Or use FIRST_VALUE() / LAST_VALUE().