Library › Coding AI › Customer support teams

Rank agents by reopen rate without small samples

Practice: Giving the right context. About 5 minutes.

About this exercise

Write one SQL query for tickets solved in October 2026 that gives each agent's reopen rate: a solved ticket counts as reopened if it has a reopened event within 7 days after solved_at. Leave out agents with fewer than 20 solved tickets in October, since small samples mislead. Return columns named exactly agent, solved, reopened and reopen_pct (rounded to 1 decimal, no integer division), highest reopen_pct first. One code block, at most 24 lines, then under 25 words outside the code.

Common mistakes when you ask AI for this

  • Leaving "reopened" vague. The AI counts every reopen event, so a ticket that bounced twice counts twice. Try: Add: "A ticket counts once if reopened within 7 days after solved_at."
  • Forgetting small samples. A temp with 6 tickets and 2 reopens tops the list. Try: Add: "Leave out agents with fewer than 20 solved."
  • Leaving the output open. The AI picks its own names, sort and math, sometimes dividing integers to 0. Try: Add: "Columns agent, solved, reopened, reopen_pct (100.0, 1 decimal), highest first."
  • Getting a menu of options. The AI likes to offer two or three versions of the query, so you're left to pick and test them yourself. Try: Add: "Give one query only, in one code block, no alternatives."
  • Getting a tutorial. By default the AI explains every part of the code at length, which you then have to scroll past. Try: Add: "After the code, one line under 12 words. Nothing else."

What a strong prompt includes

  • Defines reopened
  • Sets a minimum sample
  • Sets the month
  • Sets the output
  • Asks for one answer only

Practice this now ↑

Related exercises