What SQL techniques would you use to write efficient queries that handle edge cases seamlessly at Barclays?
Use the supplied account, transaction, and status-history tables. Write one PostgreSQL query that reports monthly settled and failed transaction metrics for active accounts, while handling missing amounts, accounts without qualifying transactions, and multiple status records.
Output
- One row per active account and month for January and February 2025
- Columns:
account_id, account_name, currency, month, settled_count, settled_amount, failed_count
- Treat missing currency as
UNKNOWN and missing numeric results as zero
- Sort by
account_id, then month ascending