Knowledge Base

How To Use The DENSE_RANK () Function on MySQL

DENSE_RANK () is a window function that assigns the rank of each row within a section or result set without spaces in the ranking of values.The row rank is increased by one from among the different rank values ​​that go before the row. The syntax for the DENSE_RANK () function is as follows:

DENSE_RANK() OVER (
PARTITION BY <expression>[{,<expression>...}]
ORDER BY <expression> [ASC|DESC], [{,<expression>...}]
)

Here is needs to specify some clarifications:

The PARTITION BY clause divides the result sets created by this FROM clause into sections. The DENSE_RANK () function is applied to each section

The ORDER BY clause determines the order of the rows in each section in which the DENSE_RANK () function works