Fill absent activity dates without replacing real zeros
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
For every supplied calendar day return day,revenue_cents,source_rows. No activity has sum0 and source_rows0; an actual zero event has source_rows1. Sort day.

OUTPUT
day, revenue_cents, source_rows

RULES
For every supplied calendar day return day,revenue_cents,source_rows. No activity has sum0 and source_rows0; an actual zero event has source_rows1. Sort day.
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
calendar:
  day TEXT — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics.
  holiday INTEGER — 1 means an explicitly closed holiday,0 otherwise.

daily:
  day TEXT — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics.
  cents INTEGER — Signed integer currency cents.

cases:
  id INTEGER — Stable source record identifier; not a row position.
  opened TEXT — ISO case opening date.
  birthday TEXT — ISO date used to demonstrate the stated anniversary policy.

fiscal_dates:
  day TEXT — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics.

METHOD
For every supplied calendar day return day,revenue_cents,source_rows. No activity has sum0 and source_rows0; an actual zero event has source_rows1. Sort day.
For the first output record, day = 2026-11-01; revenue_cents = 100; source_rows = 1.
Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

COMMON WRONG TURN
Replacing missing dates with zero but omitting source counts makes a measured zero indistinguishable from no event.

RESULT CHECK
For the first output record, day = 2026-11-01; revenue_cents = 100; source_rows = 1.

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.
