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:

  • medals: region, medal_color, medal_count

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

Practice on your own: SQL playground