INTERACTIVE LECTURES
Build and change a database
Guided class activity · apply the ideas from the full SQL lessons.
Open the detailed lessons for this activity
Detailed lessons in this module
Open the full explanations, examples, and SQL exercises directly.
Preparing for Lab 10 · After practice, try the team challenge.
Opening your saved work…
Sign in to save across devices → · Download your guest work before switching accounts.
Account for every source row without inventing an exclusion count
Step 8 of 9 · Database: Trail Gear: build rehearsal
READ & UNDERSTAND
For a first load into an empty one-to-one target, source rows should equal loaded rows plus excluded rows. Count all three independently. Computing excluded as source minus loaded guarantees the equation balances even when the load silently lost a valid row.
A reconciliation needs row-level evidence as well as totals. Trail Gear records one decision for every staging row. Compare accepted serials with loaded serials and inspect changed field values. Equal counts do not prove equal identities or correct amounts.
For appends, deduplication, bridge expansion or unpivoting, one source row may not map to one target row. Document the mapping and the appropriate units. The simple equation here applies to this fresh fixed-fixture load; it is not a universal import formula.
Worked example
SELECT decision, COUNT(*) AS rows FROM load_audit GROUP BY decision ORDER BY decision;
The audit distinguishes accepted from excluded rows using recorded decisions.
The expected counts are 6 source, 3 loaded and 3 excluded. Inspect source_row and reason to explain the three exclusions.
Your question
Return one row with source_rows from stg_items, loaded_rows from items, and excluded_rows counted from load_audit where decision is Excluded.
Explain your evidence
Could a balanced count hide the wrong serial or rate? Name an additional comparison that would expose it.
Try a query to unlock the worked-answer discussion.
Query results
Predict the result, then run your query.Predict the result, then run your query.
Read-only activity · One statement per run · First 200 rows displayed · Checks compare the complete bounded result, not just this preview.
Explore this query freely in the playground ↗Check the save status above. Account-saved work is available in My Progress. Explanations are for discussion, not automatically graded. No prerequisite locks.