개인적인 정리

[Oracle]RATIO_TO_REPORT() 본문

DB/ORACLE

[Oracle]RATIO_TO_REPORT()

yeon.Biju 2020. 4. 14. 11:03

오라클 RATIO_TO_REPORT()

 

RATIO_TO_REPORT()

   - 합계에서 각 row가 차지하는 비율을 구할 때 좋은 것 같다.

 

RATIO_TO_REPORT(expr) OVER(query_partition_clause)

의 형태

 

RATIO_TO_REPORT is an analytic function. It computes the ratio of a value to the sum of a set of values. If expr evaluates to null, then the ratio-to-report value also evaluates to null.

 

The set of values is determined by the query_partion_clause. If you omit that clause, then the ratio-to-report is computed over all rows returned by the query. 

 

You cannot nest analytic functions by using RATIO_TO_REPORT or any other analytic function for expr. However, you can use other built-in function expressions for expr

 

 

 

SQL>

SELECT 
    last_name, 
    salary, 
    RATIO_TO_REPORT(salary) OVER() AS rr
FROM employees    
WHERE job_id ='PU_CLERK'
ORDER BY last_name, salary, rr;

 

'DB > ORACLE' 카테고리의 다른 글

[Oracle]REGEXP_REPLACE()  (0) 2020.06.08
[Oracle] REGEXP_INSTR()  (0) 2020.04.21
[ORACLE] REGEXP_COUNT()  (0) 2020.04.21
[Oracle] RAWTOHEX()  (0) 2020.04.14
[Oracle] RANK()  (0) 2020.04.14
[Oracle] POWER()  (0) 2020.04.14
[Oracle] PERCENT_RANK()  (0) 2020.04.14
[Oracle]NVL2()  (0) 2020.04.13
Comments