Distributing Sales Data into Quartiles Using NTILE
📖 Scenario: You work for a retail company that wants to analyze sales performance by dividing salespeople into four groups based on their total sales. This helps identify top performers and those who may need support.
🎯 Goal: Create a SQL query that uses the NTILE function to split salespeople into four groups (quartiles) based on their total sales.
📋 What You'll Learn
Create a table called
sales with columns salesperson (text) and total_sales (integer).Insert the exact sales data for five salespeople:
'Alice' with 5000, 'Bob' with 7000, 'Charlie' with 3000, 'Diana' with 9000, and 'Evan' with 6000.Write a query that selects
salesperson, total_sales, and a quartile number using NTILE(4) ordered by total_sales descending.Name the quartile column
sales_quartile.💡 Why This Matters
🌍 Real World
Companies often group employees or customers into performance or value segments to target strategies effectively.
💼 Career
Understanding NTILE helps in data analysis roles to create meaningful groups for reporting and decision-making.
Progress0 / 4 steps