Verify complex SQL correctness
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?
cohort_retention_counts(signup_lines: list[str], activity_lines: list[str], cohort_month: str, max_offset: int) → list[int][["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][["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]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.
Vibe & agentic: describe the solution in plain language (or narrate it) and the coach grades your approach.