Explains complex SQL queries in plain English, step by step. Great for onboarding engineers or debugging unfamiliar queries.
Explain the following SQL query in plain English. Break it down step by step so a junior developer can understand it.
**Query:**
```sql
{{query}}
```
**Database context:** {{db_context}}
Structure your explanation as:
1. **What this query does** — one-sentence summary
2. **Step-by-step breakdown** — explain each clause (FROM, JOIN, WHERE, GROUP BY, etc.) in order
3. **What the result looks like** — describe the shape and content of the output
4. **Potential gotchas** — any edge cases, NULLs, or performance concerns to be aware of{{query}}long_textrequiredThe SQL query to explain{{db_context}}stringBrief description of the database schema