DENSE_RANK
ranking
What changes
- Input
- partition and ORDER BY columns of OVER
- Output or change
- one rank or number per row
- Return type
- bigint
Syntax at a glance
DENSE_RANK ( ) OVER ( [ <partition_by_clause> ] < order_by_clause > )
Work example
Rank tied values without gaps between rank numbers.
Use the business score as the rank order and add a separate sort for display if needed.
Check your work DENSE_RANK gives peers the same value and the next distinct value the next rank.
Practice SQL
Open in SQL FlowSELECT score, DENSE_RANK() OVER (ORDER BY score DESC) AS place FROM (VALUES (90), (90), (80)) AS v(score);
Open Microsoft Learn for full syntax, permissions, and details for your version.