American Express wants a monthly view of its highest-spending cardmembers. Write a PostgreSQL query to find the top three spending customers by month during the most recent 12-month period.
YYYY-MM, customer details, total spending, and the customer rank.| Column | Type | Description |
|---|---|---|
| customer_idPK | INT | Unique cardmember identifier |
| customer_name | VARCHAR(100) | Cardmember name |
| Column | Type | Description |
|---|---|---|
| card_idPK | INT | Unique American Express card identifier |
| customer_id | INT | Cardmember who owns the card |
| card_status | VARCHAR(20) | Current card status |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| card_id | INT | Card used for the transaction |
| transaction_ts | TIMESTAMP | Transaction timestamp |
| transaction_type | VARCHAR(20) | Transaction classification |
| status | VARCHAR(20) | Transaction processing status |
| amount | NUMERIC(12,2) | Transaction amount in dollars |