다른 예를 볼까요?
코드 11-16
SELECT employee_id, emp_name, dept_name, salary,
LAG(salary, 1, 0) OVER (PARTITION BY dept_name
ORDER BY salary DESC
) lag_previous,
LEAD(salary, 1, 0) OVER (PARTITION BY dept_name
ORDER BY salary DESC
) lead_next
FROM emp_hierarchy
ORDER BY 3, 4 DESC;
실행결과