Oracle9i SQL Reference Release 1 (9.0.1) Part Number A90125-01 |
|
Functions, 93 of 166
ratio_to_report::=
ratio_to_report
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, the ratio-to-report value also evaluates to null.
The set of values is determined by the query_partition_clause. If you omit that clause, the ratio-to-report is computed over all rows returned by the query.
You cannot use RATIO_TO_REPORT
or any other analytic function for expr. That is, you can use other built-in function expressions for expr, but you cannot nest analytic functions.
The following example calculates the ratio-to-report of each purchasing clerk's salary to the total of all purchasing clerks' salaries:
SELECT last_name, salary, RATIO_TO_REPORT(salary) OVER () AS rr FROM employees WHERE job_id = 'PU_CLERK'; LAST_NAME SALARY RR ------------------------- ---------- ---------- Khoo 3100 .223021583 Baida 2900 .208633094 Tobias 2800 .201438849 Himuro 2600 .18705036 Colmenares 2500 .179856115
|
Copyright © 1996-2001, Oracle Corporation. All Rights Reserved. |
|