Menu
Coddy logo textTech

Recap - RANK & DENSE_RANK

Part of the Fundamentals section of Coddy's SQL journey — lesson 66 of 72.

challenge icon

Challenge

Medium

Available tables and columns:

  • <strong>medals</strong>: <strong>region</strong>, <strong>medal_color</strong>, <strong>medal_count</strong>

Regions receive medals in competitions. Create a report that shows:

  1. Calculate for each region:
    • total_medals: The sum of all medals they have
    • rank_by_medals: Create a dense rank based on total_medals in ascending order (regions with fewer medals get better/lower ranks)
  2. Order the results by:
    • rank_by_medals (ascending)
    • region (alphabetically)

return:

  • region
  • total_medals
  • rank_by_medals

Try it yourself

All lessons in Fundamentals