Use NTILE() and PERCENT_RANK() window functions for distribution analysis
I need to segment our active sales reps into performance quartiles based on total revenue. Show each rep's name, total revenue, their quartile (1=top 25%, 4=bottom 25%), and their percentile rank (0 to 1 scale). I'm trying to identify who's in the bottom quartile for coaching and who's in the top quartile for promotion consideration.
Each hint you reveal reduces the XP you can earn. Try the query first.
First aggregate total revenue per active Sales rep in a subquery
Apply NTILE(4) OVER (ORDER BY total_revenue DESC) for quartiles (1 = highest revenue)
Apply PERCENT_RANK() OVER (ORDER BY total_revenue DESC) for percentile — it returns 0 for the top performer and 1 for the bottom