Last updated
Analyze customer profitability, loyalty, spending behavior, profit margin, and high-value customer status.
Analyze customer profitability, loyalty, spending behavior, profit margin, and high-value customer status.
Your dataset contains customer_orders with repeated customer orders, order amounts, city, and profit values.
| Column | Type | Key / Notes |
|---|---|---|
| customer_id | INT | Unique customer ID |
| customer_name | VARCHAR(50) | Customer name |
| city | VARCHAR(50) | Customer city |
| order_amount | FLOAT | Order amount |
| profit | FLOAT | Profit earned from the order |
customer_orders — 10 rows
| customer_id | customer_name | city | order_amount | profit |
|---|---|---|---|---|
| 101 | Rahul | Mumbai | 15000 | 2500 |
| 102 | Priya | Delhi | 12000 | 1800 |
| 101 | Rahul | Mumbai | 18000 | 3200 |
| 103 | Aman | Kolkata | 8000 | 900 |
| 104 | Sneha | Bangalore | 25000 | 4200 |
| 102 | Priya | Delhi | 14000 | 2200 |
| 105 | Vikram | Pune | 30000 | 5500 |
| 101 | Rahul | Mumbai | 22000 | 4100 |
| 103 | Aman | Kolkata | 11000 | 1300 |
| 105 | Vikram | Pune | 27000 | 4800 |
Calculate total sales, total profit, average order value, and total orders for each customer. Assign customer segments using sales thresholds. Calculate profit margin percentage. Rank customers based on total profit. Identify high-value customers where profit margin is above 15% and total orders are at least 2.
Your output should look like this (partial example):
| customer_id | customer_name | total_sales | total_profit | total_orders | customer_segment | profit_rank | high_value_customer |
|---|---|---|---|---|---|---|---|
| 105 | Vikram | 57000 | 10300 | 2 | Platinum | 1 | Yes |
| 101 | Rahul | 55000 | 9800 | 3 | Platinum | 2 | Yes |
| ... | ... | ... | ... | ... | ... | ... | ... |