SELECT e.*, LAG(salary) over(partition by dept_name ORDER BY emp_id) AS Pre_Employee_Sal, LEAD(salary) over(partition by dept_name ORDER BY emp_id) AS Next_Employee ...
I want to design a query to compute some returns for stock data and in searching the 'SQL Server Books Online' I find a very small and not so helpful at all help section on the lead and lag functions.