Publicis Groupe México wants to identify the highest-value customers within each product category for audience planning and campaign prioritization. Write a PostgreSQL query using joins, aggregation, and a window function.
order_status = 'completed'.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer's full name |
| Column | Type | Description |
|---|---|---|
| product_idPK | INT | Unique product identifier |
| category | VARCHAR(50) | Product category |
| product_name | VARCHAR(100) | Product name |
| Column | Type | Description |
|---|---|---|
| order_idPK | INT | Unique order identifier |
| customer_id | INT | Customer who placed the order |
| product_id | INT | Product included in the order |
| order_amount | NUMERIC(10,2) | Monetary value of the order |
| order_status | VARCHAR(20) | Order state |