Reconcile Billed Line Items Against Metered Usage for AWS Accounts

Last updated: November 29, 2026

Quick Overview

Given billing_line_items (account_id, usage_date, service, billed_qty) and raw metered_usage (account_id, usage_ts, service, qty), produce a November 2026 reconciliation at the account, day and service grain that labels each row MATCH, QTY_MISMATCH, BILLED_WITHOUT_USAGE or UNBILLED_USAGE.

Amazon
Data Manipulation (SQL/Python)
Data Engineer
Amazon
November 29, 2026
Data Engineer
Onsite
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given billing_line_items (account_id, usage_date, service, billed_qty) and raw metered_usage (account_id, usage_ts, service, qty), produce a November 2026 reconciliation at the account, day and service grain that labels each row MATCH, QTY_MISMATCH, BILLED_WITHOUT_USAGE or UNBILLED_USAGE.

AWS billing correctness is a trust issue: overbilling generates escalations and underbilling leaks revenue at enormous scale. Data engineering onsites use reconciliation questions to test FULL OUTER JOIN usage, aggregating both sides to the same grain first, and tolerances for floating point quantities.

What the Interviewer Expects
  • Aggregate both sources to the identical grain before joining
  • Use FULL OUTER JOIN so rows missing on either side surface
  • COALESCE the join keys for the output
  • Use a relative tolerance instead of exact equality for quantities
  • Point out the day-boundary problem when one side is a timestamp
Key Topics to Cover
FULL OUTER JOIN
reconciliation
grain alignment
COALESCE
tolerance
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • Metered usage is in UTC but some bills use the payer's billing timezone; how do you reconcile?
  • How would you prioritize which mismatches to investigate first?
  • How would you run this incrementally as late usage records arrive for previous days?
  • What would you alert on, and what threshold avoids alert fatigue?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data
  • billing_line_items: already rolled up to account, day and service, but may contain several line items per key (different pricing tiers), so I still sum.
  • metered_usage: raw meter records with t...
Approach
  1. Aggregate each side to (account_id, usage_date, service). Joining raw meter rows to bill rows would multiply quantities.
  2. FULL OUTER JOIN on all three keys. An inner join would hide exactly t...

Submit Your Answer
Markdown supported