Your question is Reconcile Conflicting Invoice 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.
Write a PostgreSQL query to reconcile invoice totals between Literati billing and ERP data for January 2024. Return one row per billing invoice, use the latest ERP snapshot per invoice_number, classify each invoice as match, amount_mismatch, or missing_in_erp, and show the absolute difference when both amounts exist.
| Column | Type | Description |
|---|---|---|
| invoice_id | ||
| invoice_number | ||
| member_id | ||
| invoice_date | ||
| billed_amount |
| Column | Type | Description |
|---|---|---|
| snapshot_id | ||
| invoice_number | ||
| snapshot_date | ||
| erp_amount |