Product Documentation

SQL Reference Guide

Previous Topic

Next Topic

PERCENT_RANK windowing function

Syntax

PERCENT_RANK ( ) OVER ( [ partition_by_clause ] order by_clause )

Description

The analytic function PERCENT_RANK calculates the relative rank of a value within a result set. The result of the function is float.

Example

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

EMPNO DEPTNO PROJNO PERCENT_RANK()

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

7782 10 101 0.0000000000000000000

7839 10 102 0.0000000000000000000

7934 10 102 1.0000000000000000000

7329 20 101 0.0000000000000000000

7566 20 101 0.2500000000000000000

7788 20 101 0.5000000000000000000

7876 20 101 0.7500000000000000000

7902 20 101 1.0000000000000000000

7698 30 101 0.0000000000000000000

7844 30 102 0.0000000000000000000

7900 30 102 1.0000000000000000000

7499 30 103 0.0000000000000000000

7521 30 103 0.5000000000000000000

7654 30 103 1.0000000000000000000

See Also

TOCIndex