Gallagher wants to identify its highest-value customers in each sales region for account planning and prioritization.
Write a PostgreSQL query that calculates each customer's total invoice spend and returns the top three customers within every region.
customers to invoices using customer_id.NULL invoice amount as zero and display customers with a NULL region as Unassigned.customer_id.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique customer identifier |
| customer_name | VARCHAR(100) | Customer or account name |
| region | VARCHAR(30) | Gallagher sales region |
| Column | Type | Description |
|---|---|---|
| invoice_idPK | INT | Unique invoice identifier |
| customer_id | INT | Customer associated with the invoice |
| invoice_date | DATE | Date the invoice was issued |
| amount | NUMERIC(12,2) | Invoice amount |