CUME_DIST
Calculates the cumulative distribution of a value over a set of values. The range of return values is 0 < CUME_DIST <= 1.
Example:
SELECT deptno , ename , sal, cume_dist ( ) over ( partition BY deptno ORDER BY sal DESC ) "RANK" FROM emp WHERE sal>2000; DEPTNO | ENAME | SAL | RANK --------+--------+-------+--------------------- 10 | KING | 10000 | 0.3333333333333333 10 | CLARK | 7450 | 0.6666666666666666 10 | MILLER | 6300 | 1 20 | ADAMS | 8100 | 0.16666666666666666 20 | FORD | 8000 | 0.5 20 | SCOTT | 8000 | 0.5 20 | JONES | 7975 | 0.6666666666666666 20 | SMITH | 6800 | 0.8333333333333334 20 | SMITH | 4800 | 1 30 | BLAKE | 11850 | 0.16666666666666666 30 | ALLEN | 7600 | 0.3333333333333333 30 | TURNER | 6500 | 0.5 30 | WARD | 6250 | 0.8333333333333334 30 | MARTIN | 6250 | 0.8333333333333334 30 | JAMES | 5950 | 1 (15 rows)
Top comments (0)