SQL join inflates revenue totals
An AI assistant wrote this query to report each customer's lifetime revenue. The reviewer ran it on staging (a few hundred orders) and the numbers looked right, so it shipped. On the production warehouse, totals are inflated 3-8x for high-value customers.
What is wrong, why did staging hide it, and how would you have caught it before merge?
Implement
customer_revenue_report(customer_ids: list[str], order_rows: list[str], refund_rows: list[str]) → list[str]Examples
in
[["c1","c2"],["c1,100","c1,200","c2,50"],["c1,r1","c1,r2"]]out["c1:300:2","c2:50:0"]in
[["c9"],["c9,10","c9,10","c9,10","c9,10","c9,10","c9,10","c9,10","c9,10","c9,10","c9,10"],["c9,r1","c9,r2","c9,r3","c9,r4"]]out["c9:100:4"]in
[[],["c1,100"],[]]out[]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 16 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.
Run or narrate your approach, then ask the coach.