Your question is Reconcile Ledger and Bank Balances. Start with the requirements and the two tables 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 ledger entries and bank transactions for a monthly financial model. Write a PostgreSQL query that reconciles the two sources by account and month, returning only accounts where the booked amount and bank amount do not match. Include the booked total, bank total, and the variance for each mismatched account-month pair.
| Column | Type | Description |
|---|---|---|
| entry_idPK | INT | Primary key for each ledger row |
| account_code | VARCHAR(20) | Financial account code |
| entry_date | DATE | Posting date |
| amount | DECIMAL(12,2) | Signed ledger amount |
| source_system | VARCHAR(50) | Origin of the entry |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Primary key for each bank row |
| account_code | VARCHAR(20) | Financial account code |
| transaction_date | DATE | Bank transaction date |
| amount | DECIMAL(12,2) | Signed bank amount |
| status | VARCHAR(20) | Transaction status |