Quantify reference validity within each import batch
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
Return batch,source_rows,valid_currency_pairs,invalid_currency_pairs using the exact country/currency pair rule, retaining duplicate source rows because this is ingest coverage. Sort batch.

OUTPUT
batch, source_rows, valid_currency_pairs, invalid_currency_pairs

RULES
Return batch,source_rows,valid_currency_pairs,invalid_currency_pairs using the exact country/currency pair rule, retaining duplicate source rows because this is ingest coverage. Sort batch.
Return exactly the declared columns and order. Money uses integer cents; time and date units follow the task and field dictionary. NULL is unknown and differs from numeric zero.
These are original fictional records and exercise policies. Scenario data may be shared with related tasks, whose decisions and output contracts differ.

FIELD DICTIONARY
records:
  id INTEGER — Stable source record identifier; not a row position.
  batch TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  customer TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  email TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  country TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  currency TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  qty INTEGER — Physical quantity; multiply through assembly paths when the task requires it.
  unit_price INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  total INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.
  deleted INTEGER — Tombstone flag:1 deleted,0 active; apply precedence before filtering.

country_currency:
  country TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  currency TEXT — Literal business key or category label. Match exactly and retain NULL where present.

attributes:
  record_id INTEGER — Foreign business-record identifier; match to the named source key.
  name TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  value TEXT — Measured numeric value; NULL means unobserved.

METHOD
Return batch,source_rows,valid_currency_pairs,invalid_currency_pairs using the exact country/currency pair rule, retaining duplicate source rows because this is ingest coverage. Sort batch.
For the first output record, batch = A; source_rows = 3; valid_currency_pairs = 3; invalid_currency_pairs = 0.
Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

COMMON WRONG TURN
Deduplicating before an ingestion-quality report changes the source row denominator.

RESULT CHECK
For the first output record, batch = A; source_rows = 3; valid_currency_pairs = 3; invalid_currency_pairs = 0.

Use setup.sql in a fresh SQLite database and run your own SELECT or WITH. reference.sql and expected.csv contain the full worked answer. All CSVs have UTF-8 headers; empty output fields represent NULL. The browser executes SQLite, not Excel formulas. No spreadsheet function engine is claimed.
