Your question is Reconcile ERP and Ledger Month-End Totals. 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 ERP transaction data and a month-end ledger summary. Write a PostgreSQL query that compares the two sources by account and month-end date, then returns only the rows that do not reconcile. Your output should show the month-end date, account code, ERP total, ledger total, and a reconciliation flag that identifies matches, mismatches, and missing-source cases.
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Primary key for each ERP transaction |
| account_code | VARCHAR(20) | Financial account code |
| transaction_date | DATE | Posting date in the ERP system |
| amount | DECIMAL(12,2) | Transaction amount, positive or negative |
| Column | Type | Description |
|---|---|---|
| account_code | VARCHAR(20) | Financial account code |
| month_end | DATE | Month-end date for the ledger summary |
| ledger_amount | DECIMAL(12,2) | Month-end ledger balance |