SELECT employee_id, department_id, salary,
LAG(salary, 1) OVER w AS prev_salary,
LEAD(salary, 1) OVER w AS next_salary,
salary - LAG(salary, 1) OVER w AS salary_diff
FROM employees
WINDOW w AS (PARTITION BY department_id ORDER BY hire_date);
如果某部门只有一个员工,该员工的prev_salary、next_salary和salary_diff分别是什么?
