Code Room
Vibe codingHardvc-g386
Subject Ai code comprehensionLevel Senior–Staff~22 minCommon in Databases & SQL interviewsIndustries Software development, Technology

Question

An analyst pastes a slow report query into an AI assistant and asks what it does. The agent says: "It returns one row per customer with their total order count and lifetime revenue, excluding customers with no orders." You're about to use this query as the source of truth for a churn dashboard. How do you verify the explanation, and what would you specifically distrust?

sql
SELECT c.id, c.name, COUNT(o.id) AS orders, SUM(o.amount) AS revenueFROM customers cLEFT JOIN orders o ON o.customer_id = c.idLEFT JOIN refunds r ON r.order_id = o.idGROUP BY c.id, c.name;
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.

Describe your solution

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.