Explain how you would approach analyzing enrollment and billing data to identify discrepancies in monthly customer invoices for an Infosys client.
Write a SQL query that compares monthly enrolled amounts to monthly billed amounts and flags customers where the two totals do not match. Focus on invoice-level discrepancies for each customer and month.
customer_id, invoice_month, enrolled_amount, billed_amount, differenceenrolled_amount and billed_amount are not equalinvoice_month, then customer_id| Column | Type | Description |
|---|---|---|
| enrollment_idPK | INT | Unique enrollment record identifier |
| customer_id | INT | Customer identifier |
| enrollment_date | DATE | Date the customer was enrolled |
| enrolled_amount | DECIMAL(10,2) | Amount recognized from enrollment |
| enrollment_status | VARCHAR(20) | Enrollment status such as active or pending |
| Column | Type | Description |
|---|---|---|
| billing_idPK | INT | Unique billing record identifier |
| customer_id | INT | Customer identifier |
| billing_date | DATE | Date the invoice was billed |
| billed_amount | DECIMAL(10,2) | Amount billed on the invoice |
| invoice_status | VARCHAR(20) | Invoice status such as posted, void, or pending |