CASE WHEN for Dynamic Sorting and Bucketing
Hard
case-when
Coinbase
Netflix
Spotify
Write a query that buckets employees into performance tiers based on their sales amount and calculates aggregate stats per tier. Tiers: 'Top Performer' (sales >= 10000), 'Solid' (sales >= 5000), 'Developing' (sales < 5000). Return tier, employee_count, and avg_sales (rounded to 2), ordered by avg_sales DESC.
Expected Output: Performance tiers with count and average sales.
Tables
Hints (3 available)
SQL Editor
Output
Click "Run" to see results...