Find the orders whose totals do not add up

Try this labAll DEA-C01 practice

Certification
DEA-C01
Format
SQL query
Difficulty
medium
Estimated time
14 min
Automated checks
8

SCENARIO

A checkout change has left some order headers disagreeing with their landed line items. Finance needs a trustworthy exception list before settlement, and an order whose line items never arrived is still an exception.

TASK

Repair order-total-audit.sql against orders and order_lines.

  • Return exactly order_id, expected_cents, calculated_cents, and difference_cents for each mismatch, once per order.
  • calculated_cents includes all line_cents and is zero when none arrived; difference_cents is expected minus calculated.
  • Exclude matching totals.

Part of DEA-C01 preparation