본문 바로가기
Oracle

[윈도우 함수] 범위를 주어서 집계값을 조회

by 캡틴노랑이 2015. 7. 29.
반응형
select
  employee_id
  ,salary
  ,sum(salary) over(partition by department_id order by employee_id
                  rows between unbounded preceding and unbounded following) w1
  ,sum(salary) over(partition by department_id order by employee_id
                  rows between unbounded preceding and  current row) w1
  ,sum(salary) over(partition by department_id order by employee_id
                  rows between  current row and unbounded following) w1

from employees
where department_id = 60;

 

반응형

댓글