Library › Data AI › Business analysts
Find the three bugs in an AI-written SQL query
- For Business analysts
- You practice Catching mistakes and made-up facts
- Time about 5 minutes
- Level Advanced
About this exercise
An AI wrote this query for orders per customer by region, but the numbers look wrong. Write exactly 3 plain-text lines labeled Bug 1:, Bug 2: and Bug 3:, under 100 words, each naming the problem and the fix in the same line. No code block, and don't rewrite the whole query.
Common mistakes when you ask AI for this
- Rewriting the whole query. The AI posts a corrected query in a code block. Try: Add: "No code block and no full rewrite; fix in the same line."
- Missing the filter placement. The AI adds status and dates in WHERE, so the LEFT JOIN still drops customers. Try: Add: "Put paid status and the October range in the ON clause."
- Stopping at the join. The AI finds the join bug and misses integer division and the distinct count. Try: Add: "Bug 3: integer division and COUNT(DISTINCT c.customer_id)."
- Leaving the format to chance. The AI picks its own length and layout unless told the exact shape. Try: Add: "Plain text, no bold or headings."
- Trusting the AI to count words. AI is bad at counting. Ask for a total word limit and it often lands over it. Try: Cap each part instead, for example "each line under 15 words."
What a strong prompt includes
- Asks for three labels
- Names the join
- Names the filters
- Names integer division
- Rules out code
Related exercises
- Accrue unpaid wages for the working days after the last pay period (Finance AI · Accountants)
- Age a returns queue in business days and flag the ones over the limit (Customer Support & Success AI · Customer support teams)
- Alert sales to a competitor's price change, facts only (Research & AI Search · Product managers)
- Annualize recurring revenue without the one-time fee (Data AI · Finance and accounting)
- Answer a credit dispute with the full-hour rule and the math (Customer Support & Success AI · Customer support teams)