Your question is Find Customers Above Department Average. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given customer spend data across departments. Write a SQL query that returns each customer whose total spend is above the average spend of customers in the same department.
| Column | Type | Description |
|---|---|---|
| department_idPK | INT | Primary key for the department |
| department_name | VARCHAR(100) | Human-readable department name |
| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Primary key for the customer |
| customer_name | VARCHAR(100) | Customer name |
| department_id | INT | Department the customer belongs to |
| spend | NUMERIC(12,2) | Total spend for the customer |