Recall & Review
beginner
What does the RANK() function do in SQL?
RANK() assigns a rank number to each row within a partition of a result set, with gaps in ranking when there are ties.
Click to reveal answer
beginner
How does DENSE_RANK() differ from RANK() in SQL?
DENSE_RANK() assigns ranks without gaps, so tied rows get the same rank and the next rank is the immediate next number.
Click to reveal answer
intermediate
If two rows tie for rank 2, what rank will the next row get with RANK()?
The next row will get rank 4, because RANK() leaves gaps after ties.
Click to reveal answer
intermediate
If two rows tie for rank 2, what rank will the next row get with DENSE_RANK()?
The next row will get rank 3, because DENSE_RANK() does not leave gaps after ties.
Click to reveal answer
intermediate
Why might you choose DENSE_RANK() over RANK()?
Choose DENSE_RANK() when you want continuous ranking numbers without gaps, useful for compact ranking lists.
Click to reveal answer
What happens to the rank numbers after a tie when using RANK()?
✗ Incorrect
RANK() skips rank numbers after ties, creating gaps.
Which function assigns ranks without gaps after ties?
✗ Incorrect
DENSE_RANK() assigns ranks without gaps after ties.
If two rows tie for first place, what rank does the next row get with DENSE_RANK()?
✗ Incorrect
DENSE_RANK() assigns the next rank as 2 after two tied rows at rank 1.
Which ranking function can produce gaps in the ranking sequence?
✗ Incorrect
RANK() produces gaps in ranking numbers after ties.
What is a key difference between RANK() and DENSE_RANK()?
✗ Incorrect
RANK() leaves gaps after ties; DENSE_RANK() assigns consecutive ranks without gaps.
Explain how RANK() and DENSE_RANK() handle ties differently in SQL.
Think about what happens to the next rank number after a tie.
You got /3 concepts.
Describe a scenario where you would prefer to use DENSE_RANK() instead of RANK().
Consider when gaps in ranking numbers might confuse users.
You got /3 concepts.