Skip to main content
1 of 2
Tigerjz32
  • 417
  • 3
  • 11

Windowed function LAG should give you the answer - https://msdn.microsoft.com/en-us/library/hh231256.aspx. This function allows it so you don't have to join to get [current]-nth value

SELECT *,
LAG([ENTRY_DATE], 1, NULL) 
    OVER (PARTITION BY [ID], [STATE], [ENTRY_DATE] ORDER BY [ENTRY_DATE]) AS EXIT_DATE
FROM table;
Tigerjz32
  • 417
  • 3
  • 11