Complex~36min
The Rep Whose Rank Doesn't Match Their Revenue
REP-001 is officially ranked #1 for Q3 bonus purposes — but that ranking was computed from total revenue, which includes a single ₹900,000 one-time deal that policy says should never count. Recomputing rank from recurring revenue only, REP-001 actually sits at #5. REP-002 through REP-005 also each carry one huge outlier deal pushing them to the top, but theirs are genuinely recurring enterprise contracts — they legitimately belong there.
Tables you'll query
sales_repsdealsofficial_rankings
What you'll learn
CTEs (WITH clause)Window Functions