AI SQL Query Explainer
Walks your query in real execution order, not written order.
Any dialect — PostgreSQL, MySQL, SQL Server, or generic ANSI SQL.
FROM through LIMIT, the order SQL actually runs in — not the order it's written in.
Why a SELECT alias can't be used in WHERE, and when HAVING is doing WHERE's job inefficiently.
Most SQL explainers paraphrase a query clause by clause in the order it's written — SELECT, then FROM, then WHERE — which reads naturally but is backwards from how SQL actually executes. This tool walks the query in real logical execution order instead: FROM, then JOIN, then WHERE, then GROUP BY, then HAVING, then SELECT, then DISTINCT, then ORDER BY, then LIMIT. That order is the actual mechanism behind two things that trip people up constantly. Given `SELECT department, COUNT(*) as emp_count FROM employees WHERE status = 'active' GROUP BY department HAVING COUNT(*) > 5 ORDER BY emp_count DESC`, the explanation states plainly why `WHERE emp_count > 5` would fail if someone tried it: WHERE is logically evaluated before SELECT, so the `emp_count` alias defined in SELECT doesn't exist yet at the point WHERE runs — HAVING has to be used instead, precisely because it operates later in the execution order, after GROUP BY has already produced the groups SELECT will project from. The same walkthrough flags WHERE-vs-HAVING misuse directly: HAVING filters groups after aggregation, so using it for a condition that doesn't involve an aggregate function like COUNT or SUM means rows get grouped first and filtered second, doing unnecessary work that a WHERE clause earlier in the execution order would have avoided. Competing SQL explainer tools that paraphrase in written order can restate what a query does, but they can't easily explain why an alias fails in WHERE or why HAVING misuse is inefficient, because those are consequences of execution order, not surface syntax. It's built for anyone reading a query they didn't write — reviewing a PR, debugging a report that's returning the wrong rows, or learning SQL past the tutorial stage where clause order starts actually mattering. One honest limitation: query planner behavior (indexes used, actual cost) varies by database engine and real data distribution — this explains logical execution order and intent, not a live EXPLAIN plan from your specific database. Built by EngraveOcean as part of a small, growing set of free AI developer utilities, alongside AI JSON Schema Explainer and AI Error/Stack Trace Explainer — no login, no daily cap.