Business Intelligence Path · Mission 11 of 25Medium

Rank the sales team

Use RANK() and ROW_NUMBER() window functions to create leaderboards

Back to Business Intelligence

The Brief

Marcus WebbVP of Salessales-ops

I need a ranked leaderboard of all active sales reps by total revenue. Show their name, total revenue, rank (with ties getting the same rank), and a unique row number. The top performer should be rank 1. I want to see where the gaps are between tied reps.

You'll practice

RANK()ROW_NUMBER()Window functions

Tables available

fact_salesdim_employees

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Use RANK() OVER (ORDER BY total_rev DESC) for rank with ties and ROW_NUMBER() OVER (ORDER BY total_rev DESC) for unique numbering

Hint 2

You need to aggregate revenue first, then apply window functions — use a subquery to get per-rep totals, then SELECT with window functions on top

Hint 3

Filter to active Sales department employees in the inner query