How do you ensure data accuracy when working with complex financial datasets?
Using the supplied January 2025 loan snapshots and payment transactions, write a SQL query that identifies records where the reported ending balance does not reconcile with the opening balance and principal payments.
loan_id, snapshot_date, reported_ending_balance, calculated_ending_balance, discrepancy_amount, and accuracy_status.loan_id.| Column | Type | Description |
|---|---|---|
| loan_idPK | VARCHAR(20) | Unique loan identifier |
| snapshot_date | DATE | Date of the reported loan balance |
| opening_balance | NUMERIC(14,2) | Balance at the start of the reporting period |
| reported_ending_balance | NUMERIC(14,2) | Balance reported at the end of the period |
| Column | Type | Description |
|---|---|---|
| payment_idPK | VARCHAR(20) | Unique payment identifier |
| loan_id | VARCHAR(20) | Loan associated with the payment |
| payment_date | DATE | Date the payment was posted |
| principal_paid | NUMERIC(14,2) | Principal component of the payment |