Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

CUME_DIST windowing function

Syntax

CUME_DIST ( ) OVER ( [ partition_by_clause ] order_by_clause )

Description

The analytic function CUME_DIST calculates the cumulative distribution of a value within a group of values. The cumulative distribution of a value is the relative position of a specified value in a group of values. With a value set ordered by ascending values, the CUME_DIST of a value for a given row is defined as the number of rows with values less than or equal to the value in the given row, divided by the number of rows evaluated in the partition. The result of the function is float.

Example

select empno, deptno, projno, cume_dist() over (partition by deptno, projno order by empno) from emp;

EMPNO DEPTNO PROJNO CUME_DIST()

----- ------ ------ -----------

7782 10 101 1.0000000000000000000

7839 10 102 0.5000000000000000000

7934 10 102 1.0000000000000000000

7329 20 101 0.2000000000000000000

7566 20 101 0.4000000000000000000

7788 20 101 0.6000000000000000000

7876 20 101 0.8000000000000000000

7902 20 101 1.0000000000000000000

7698 30 101 1.0000000000000000000

7844 30 102 0.5000000000000000000

7900 30 102 1.0000000000000000000

7499 30 103 0.3333333333333330000

7521 30 103 0.6666666666666670000

7654 30 103 1.0000000000000000000

See Also

TOCIndex