Warn when a currently valid direct grant expires before the next request Original fictional practice · CC BY 4.0 · 2026-11-11 TASK At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_id. OUTPUT grant_id, next_request_day, expires RULES At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_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 grants: id INTEGER — Stable source record identifier; not a row position. principal TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present. effect TEXT — Permission outcome, allow or deny. expires INTEGER — Expiry boundary; the goal declares whether equality is eligible. mask INTEGER — Privacy mask level; higher values require stricter masking. members: member TEXT — Literal business key or category label. Match exactly and retain NULL where present. parent TEXT — Immediate parent identifier, or NULL for a hierarchy root. requests: id INTEGER — Stable source record identifier; not a row position. user TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource 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. approvals: id INTEGER — Stable source record identifier; not a row position. requester TEXT — Literal business key or category label. Match exactly and retain NULL where present. approver TEXT — Literal business key or category label. Match exactly and retain NULL where present. resource TEXT — Literal business key or category label. Match exactly and retain NULL where present. METHOD At day0 consider direct user allow grants with expires>0. For each find the first same-principal/resource request on or after day0. Return grant_id,next_request_day,expires if next request is at or after expiry. Sort grant_id. For the first output record, grant_id = 5; next_request_day = 10; expires = 5. Inspect the source grain, keys and ties. Compare each result column with the full worked SQL and expected CSV. COMMON WRONG TURN Looking only at grant validity today misses a predictable credential expiry before the next scheduled access. RESULT CHECK For the first output record, grant_id = 5; next_request_day = 10; expires = 5. 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.