RATIO_TO_REPORT
Purpose
This function computes the ratio of a value to the overall sum.
Syntax
ratio_to_report::=
Usage Notes
RATIO_TO_REPORT
is only available as an analytic function (i.e., in combination with an over_clause). For more information, refer to Analytic Functions section.- The
over_clause
must not include anorder_clause
or awindow_frame_clause
. For more information, refer to Analytic Functions section.
Example
Analytic Function
SELECT
id, department, current_salary,
RATIO_TO_REPORT(current_salary) OVER (PARTITION BY department) RATIO_TO_REPORT
FROM employee_table ORDER BY department, current_salary;
Result
ID | DEPARTMENT | CURRENT_SALARY | RATIO_TO_REPORT |
2001 | ACCOUNTS | 55000 | 0.15714286 |
2002 | ACCOUNTS | 65000 | 0.18571429 |
2004 | ACCOUNTS | 70000 | 0.2 |
2003 | ACCOUNTS | 80000 | 0.22857143 |
2005 | ACCOUNTS | 80000 | 0.22857143 |
1001 | HR | 55000 | 0.19298246 |
1002 | HR | 70000 | 0.24561404 |
1004 | HR | 70000 | 0.24561404 |
1003 | HR | 90000 | 0.31578947 |