PL/SQL Cume_Dist

Oracle PL/SQL Cume_Dist Function

The Cume_Dist function returns the relative position of a row within a group meeting certain criteria.

The Cume_Dist Function syntax:

cum_dist(exp1,… WITHIN GROUP (ORDER BY)

Aggregate Function Example:

Select cume_dist(1200, 500) WITHIN GROUP (ORDER BY e.sal, e.comm) 
From emp e ;

Analytic Function Example:

Select e.ename, e.sal, 
cume_dist() OVER (PARTITION BY e.deptno ORDER BY e.sal) 
From emp e
Where e.job='CLERK' ;