答案 0 :(得分:2)
您可以使用LEAD
和LAG
窗口函数:
SELECT *,
PreviousShiftProfileID = LAG(ShiftProfileID) OVER(PARTITION BY EmployeeID ORDER BY CDate),
NextShiftProfileID = LEAD(ShiftProfileID) OVER(PARTITION BY EmployeeID ORDER BY CDate)
FROM yourTable