Your question is Reconcile ERP and Planning Balances. Start with the requirements and the one table on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
You are given a single reconciliation table that contains balance snapshots from two sources: ERP and a planning tool. Write a PostgreSQL query that returns each account with its ERP balance, planning balance, and the variance between them, then sort the accounts by the largest absolute variance. Treat missing source values as zero when calculating variance.
| Column | Type | Description |
|---|---|---|
| account_id | INT | Account identifier |
| account_name | VARCHAR(100) | Account name |
| source_system | VARCHAR(20) | Source system name, such as ERP or Planning |
| as_of_date | DATE | Snapshot date |
| balance_amount | DECIMAL(12,2) | Reported balance amount |