Spend and Rank
A hard SQL interview practice problem on DataDriven. Write and execute real sql code with instant grading.
- Domain
- SQL
- Difficulty
- hard
- Seniority
- L5
Problem
The executive team wants a leaderboard of the 5 biggest spenders for the quarterly review. Sum spending per user, assign positions starting at 1 for the biggest spender with ties sharing a position, and keep only users in the top 5 positions. Return the username, total spend, and position.
Summary
Five thrones at the top of the spending leaderboard.
Practice This Problem
Solve this SQL problem with real code execution. DataDriven runs your SQL queries against a real database and grades it automatically.