DENSE_RANK function in Oracle

DENSE_RANK is one of the vital Analytic functions of Oracle. It is used to get the rank of a row in a group of rows. It always results in the consecutive ranking of the rows. The DENSE_RANK function is supported in the various versions of the Oracle/PLSQL, including, Oracle 12c, Oracle 11g, Oracle 10g and Oracle 9i.

Syntax:

DENSE_RANK ( expr_1, expr_2, .. expr_n ) WITHIN GROUP ( ORDER BY expr_1, expr_2, .. expr_n  )

Parameters: expr_1, expr_2, .. expr_n: They are used to specify the expressions to be used for identifying a unique row in the group.

Example:

select DENSE_RANK(100, 20) WITHIN GROUP (ORDER BY marks, extra)
from students;

Explanation: Here, the dense rank of a student with a total marks of 100 and an extra marks of 20 from within the students table will be returned.

Please follow and like us:
Content Protection by DMCA.com