Write a SQL query to aggregate monthly transaction volumes and identify reconciliation anomalies across multiple ledger tables.
Use posted transactions and completed settlements. Treat a month as anomalous when transaction counts or monetary volumes differ.
month_start, transaction_count, transaction_volume, settlement_count, settlement_volume, volume_difference, and reconciliation_status.month_start ascending, and label each row MATCHED or ANOMALY.| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| transaction_date | DATE | Date the transaction was recorded |
| amount | NUMERIC(12,2) | Transaction monetary amount |
| status | VARCHAR(20) | Transaction processing status |
| Column | Type | Description |
|---|---|---|
| settlement_idPK | INT | Unique settlement record identifier |
| transaction_id | INT | Related transaction identifier when available |
| settled_at | DATE | Date the settlement was recorded |
| settled_amount | NUMERIC(12,2) | Settlement monetary amount |
| status | VARCHAR(20) | Settlement processing status |