Code RoomVerify complex SQL correctness
HardPrep Room Coding #4099

Verify complex SQL correctness

Vibe & agenticDatabases & SQLSenior–Staff~21 min

An agent produced a gnarly 60-line SQL query (window functions, multiple CTEs, a correlated subquery) to compute monthly cohort retention for a leadership dashboard. It runs, returns plausible numbers, and you don't fully follow the windowing logic. You're about to wire it into a report executives will make decisions on. How do you verify it's correct before you ship — without just trusting it and without spending a day re-deriving it by hand?

Implement
cohort_retention_counts(signup_lines: list[str], activity_lines: list[str], cohort_month: str, max_offset: int) → list[int]
Examples
in[["u1|2026-01-05","u2|2026-01-20","u3|2026-02-02","u4|2026-01-31"],["u1|2026-02-11","u1|2026-02-28","u2|2026-03-01","u3|2026-02-03"],"2026-01",2]out[3,1,1]
in[["a|2025-12-31","b|2025-12-01"],["a|2026-01-15","a|2026-01-16","b|2026-02-02","a|2026-03-05","b|2026-03-05"],"2025-12",3]out[2,1,1,2]
What a strong answer looks like

Treat the AI’s output as a draft to verify, not an answer to trust. Name the specific flaw and the input that triggers it, say how you’d catch it (tests, edge cases, reading critically), and how you’d re-prompt or decompose to get it right.

0:00 of about 21 min

Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.

Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.