Many relational database management systems (RDBMSs) provide a DENSE_RANK()
function that we can use in our SQL queries. The SQL DENSE_RANK()
function is a window function that returns the rank of the current row within its partition, without gaps.
The “without gaps” part is what distinguishes the DENSE_RANK()
function from the RANK()
function.
DENSE_RANK()
returns contiguous rank numbers whenever there are ties, whereas RANK()
will leave a gap between the tie and the next rank, resulting in noncontiguous rank numbers.