Measure maximum simultaneous bookings
Original fictional practice · CC BY 4.0 · 2026-11-11

TASK
Bookings occupy [start,end); an end and start at the same minute do not overlap. Return resource,peak_concurrent from endpoint segments, sorted resource.

OUTPUT
resource, peak_concurrent

RULES
Bookings occupy [start,end); an end and start at the same minute do not overlap. Return resource,peak_concurrent from endpoint segments, sorted resource.
Return exactly the declared columns and order. Money uses integer cents; all time values are elapsed UTC minutes unless a field is explicitly a day index. NULL is unknown and differs from numeric zero.
These are original fictional records and exercise policies. All source tables in this case are included in the downloadable pack.

FIELD DICTIONARY
slots:
  id INTEGER — Stable record or business key; retain its declared type.
  resource TEXT — Literal text label or key; comparisons use SQLite binary text semantics.
  start INTEGER — Exact integer measurement; use the task rule for units and ordering.
  end INTEGER — Exact integer measurement; use the task rule for units and ordering.
  priority INTEGER — Exact integer measurement; use the task rule for units and ordering.

requests:
  id INTEGER — Stable record or business key; retain its declared type.
  resource TEXT — Literal text label or key; comparisons use SQLite binary text semantics.
  minute INTEGER — Exact integer measurement; use the task rule for units and ordering.
  duration INTEGER — Exact integer measurement; use the task rule for units and ordering.

METHOD
Bookings occupy [start,end); an end and start at the same minute do not overlap. Return resource,peak_concurrent from endpoint segments, sorted resource.
Inspect the source grain, keys and ties before writing the query. Use the worked SQL and complete expected CSV to review any mismatch.

COMMON WRONG TURN
Counting both interval endpoints as occupied reports a false clash at minute 30.

RESULT CHECK
The independent JavaScript solver and actual SQLite reference must agree on every output cell.

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.
