Chapter 5 · Q.52 · Easy · Typical in tests at Infosys, Wipro
The sales manager at a consumer electronics company in Mumbai needs to rank reps by revenue for January 2026. Three reps hit the exact same number that month, and the manager wants the ranking to reflect that tie honestly, with a gap after it.
SELECT
rep_name,
revenue_inr,
RANK() OVER (ORDER BY revenue_inr DESC) AS revenue_rank
FROM sales_performance sp
JOIN sales_team st ON sp.rep_id = st.rep_id
WHERE quarter = '2026Q1'
AND month = '2026-01'
ORDER BY revenue_rank, rep_name;| rep_name | revenue_inr | revenue_rank |
|---|---|---|
| Aditya Joshi | 520000.00 | 1 |
| Neha Gupta | 480000.00 | 2 |
| Pooja Patel | 480000.00 | 2 |
| Ravi Shankar | 480000.00 | 2 |
| Siddharth Rao | 310000.00 | 5 |
Common mistake: Expecting RANK() to return 1, 2, 2, 2, 3. RANK() skips numbers after ties. After three reps share rank 2, the next rank is 5, not 3.
Key insight: RANK() leaves gaps after ties. If three people tie at rank 2, the next person gets rank 5. This matches how sports rankings work.






