그럼 실제 쿼리를 작성해 프레임 절의 구성에 따라 결과가 어떻게 달라지는지 봅시다.
코드 11-21
SELECT employee_id, emp_name, dept_name, salary,
SUM(salary) OVER (PARTITION BY dept_name
ORDER BY salary DESC
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) rows_value,
SUM(salary) OVER (PARTITION BY dept_name
ORDER BY salary DESC
RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
) range_value
FROM emp_hierarchy
WHERE dept_name IN ('IT', 'Finance')
ORDER BY 3, 4 DESC;
실행결과