CS/데이터베이스
[Oracle] 데이터 분석 - 비율 출력 (RATIO_TO_REPORT)
김크롱
2020. 9. 10. 10:49
데이터 분석 - 비율 출력 (RATIO_TO_REPORT
: 특정 컬럼의 데이터 합계를 기준으로 각 로우의 상대적 비율을 구함
SELECT column1, column2, column3, RATIO_TO_REPORT(column3) OVER() as nickname
FROM tablename
WHERE column4=100;
: column4가 100일 경우, column1, column2, column3와 100일 경우 내에서 column3의 비율을 출력
SELECT column1, column2, column3, RATIO_TO_REPORT(column3) OVER() as 비율,
SAL/SUM(column3) OVER() as 비교비율
FROM tablename
WHERE column4=100;
: RATIO_TO_REPORT() = SAL/SUM()