A financial reporting team needs a quarterly view of its highest-spending clients by region. Write a PostgreSQL query to identify the top three clients in each non-null region based on transaction amounts from the previous calendar quarter relative to the fixed reporting date of September 15, 2026.
region, client_id, client_name, total_spent, and spending_rank.SUM ignores NULL amounts, so a client whose qualifying amounts are all NULL has a NULL total_spent.client_id as the deterministic tie-breaker.region, then spending_rank, then client_id.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| client_id | INT | Identifier of the client associated with the transaction |
| client_name | VARCHAR(120) | Client name |
| region | VARCHAR(60) | Client reporting region |
| transaction_date | DATE | Date on which the transaction occurred |
| amount | DECIMAL(14,2) | Transaction amount in the reporting currency |