테이블 table_123에서 점이 1100인 것의
select mngbr, cifno, jikwonno, janamt
, row_number() over(partition by jikwonno order by mngbr, cifno ) accum -- 직원별 순차번호
, sum(janamt) over(partition by jikwonno order by mngbr, cifno rows between unbounded preceding and current row) accum1 -- 점,직원별/ 고객번호순 잔액의 누적
, sum(janamt) over(partition by jikwonno) accum_tot -- 점,직원별 잔액의 합계
, round(ratio_to_report(janamt) over(partition by jikwonno), 2)*100 ratio_tot -- 점,직원별 잔액이 차지하는 비율
from table_123
where mngbr = 1100
, row_number() over(partition by jikwonno order by mngbr, cifno ) accum -- 직원별 순차번호
, sum(janamt) over(partition by jikwonno order by mngbr, cifno rows between unbounded preceding and current row) accum1 -- 점,직원별/ 고객번호순 잔액의 누적
, sum(janamt) over(partition by jikwonno) accum_tot -- 점,직원별 잔액의 합계
, round(ratio_to_report(janamt) over(partition by jikwonno), 2)*100 ratio_tot -- 점,직원별 잔액이 차지하는 비율
from table_123
where mngbr = 1100
[출처] 오라클 분석함수 - 누적,합계,비율구하기 |작성자 아직이군
분석함수가 약한 나에게 한줄기 빛이되신 아직이군님께 감사드립니다.


::: 사람과 사람의 교감! 人터넷의 첫 시작! 댓글을 달아주세요! :::