Oracle8i SQL Reference Release 2 (8.1.6) A76989-01 |
|
Functions, 71 of 121
For information on syntax and semantics, see "Analytic Functions".
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.
The following example calculates the ratio-to-report of each salesperson's salary to the total of all salespeople's salaries:
SELECT ename, sal, RATIO_TO_REPORT(sal) OVER () AS rr FROM emp WHERE job = 'SALESMAN'; ENAME SAL RR ---------- ---------- ---------- ALLEN 1600 .285714286 WARD 1250 .223214286 MARTIN 1250 .223214286 TURNER 1500 .267857143
|
![]() Copyright © 1999 Oracle Corporation. All Rights Reserved. |
|