Why it matters
One missing event and one duplicate can cancel each other in a row count. If a downstream report drives customer contact, the wrong row may reach the wrong person.
Core concepts
Scope and time
Agree on business keys, timezone, cutoffs and correction window before comparing tables. Record event time and ingestion time. A late-arriving correction can produce a legitimate mismatch until the next run.
Classify mismatches
Check missing on target, extra on target, duplicates, field disagreements and unresolved matches separately. Compare counts, amounts and key sets. Restrict each field comparison to the same business moment to avoid comparing a new state with an old snapshot.
Separate completeness from accuracy
A valid format proves little about ownership or real-world correctness. A required identifier can be present but point to the wrong account. A control report should show unmatched keys, disposition, age and owner. Use independent samples for the rows that did match.
Try it step by step
- Capture both populations at an agreed cutoff. Check key uniqueness before comparing rows.
- Use an anti-join in each direction. Compare important fields and compute both net and absolute differences.
- Give each exception a reason and owner. Set a safe re-run rule, then trace a small sample through the consumer-facing report.
Keep a reconciliation statement: source scope, target scope, snapshot times, match rules, differences by type, remaining impact and reviewer.
Worked example
Hypothetical example. Source keys are A, B, C. Target keys are A, B, B. Both extracts have three rows. The target has two unique keys, C is missing and B is duplicated. A count-only control would declare success. A key-set check shows exactly where the repair belongs.
WITH source(id) AS (VALUES ('A'),('B'),('C')),
target(id) AS (VALUES ('A'),('B'),('B'))
SELECT s.id AS missing_in_target
FROM source s
WHERE NOT EXISTS (
SELECT 1 FROM target t WHERE t.id = s.id
)
ORDER BY s.id;Common mistake
Reporting only the net amount difference. An underpayment of 10 and an overpayment of 10 net to zero.
Practice exercise
Run this fixture. It returns C as missing. Reverse the inputs to find extra keys, then group target rows by id with HAVING COUNT(*) > 1 to find duplicate B.
Check your understanding
Two extracts each contain 100 rows. What can you conclude?
- The keys and totals match
- Only that the row counts match
- All records arrived on time
Show answer
Only that the row counts match. A duplicate can offset a missing record. Compare key sets, multiplicity, fields and cutoff times.
Takeaway
Match the keys first. Compare the values second. Explain the rest.