Value facts using one authoritative temporal version
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
At cutoff15 choose latest recorded valid version per fact, suppress tombstones and retain unmatched facts asNULL unit_value and extended_value. Return fact_id,unit_value,extended_value=amount*value sorted fact_id.

OUTPUT
fact_id, unit_value, extended_value

RULES
At cutoff15 choose latest recorded valid version per fact, suppress tombstones and retain unmatched facts asNULL unit_value and extended_value. Return fact_id,unit_value,extended_value=amount*value sorted fact_id.
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
versions:
  id INTEGER — Stable source record identifier; not a row position.
  entity TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  valid_from INTEGER — Inclusive valid-time start day.
  valid_to INTEGER — Exclusive valid-time end day.
  recorded INTEGER — Transaction-time day index when this version became known.
  value INTEGER — Measured numeric value; NULL means unobserved.
  deleted INTEGER — Tombstone flag:1 deleted,0 active; apply precedence before filtering.

facts:
  id INTEGER — Stable source record identifier; not a row position.
  entity TEXT — Literal business key or category label. Match exactly and retain NULL where present.
  day INTEGER — Integer day index, or ISO YYYY-MM-DD date when stored as text; the task declares cutoff semantics.
  amount INTEGER — Exact integer business measurement. Its specific business rule and eligibility are declared in the task.

METHOD
At cutoff15 choose latest recorded valid version per fact, suppress tombstones and retain unmatched facts asNULL unit_value and extended_value. Return fact_id,unit_value,extended_value=amount*value sorted fact_id.
For the first output record, fact_id = 1; unit_value = 110; extended_value = 220.
Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV.

COMMON WRONG TURN
Joining every matching version multiplies fact amounts and leaks superseded values into the report.

RESULT CHECK
For the first output record, fact_id = 1; unit_value = 110; extended_value = 220.

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.
