
Write a PostgreSQL query that compares monthly billed amount by American Express card product in 2024 against both the prior month and the same month in the prior year. Only include posted transactions, and return NULL when a comparison period does not exist.
| Column | Type | Description |
|---|---|---|
| transaction_id | ||
| card_member_id | ||
| product_id | ||
| transaction_date | ||
| amount | ||
| status |
| Column | Type | Description |
|---|---|---|
| product_id | ||
| product_name | ||
| product_family |
One row per product per month in 2024Current month billed amountPrior month billed amountPrior year billed amountPercent change versus each comparison period