SQL Quest › Free SQL tools › SQL Query Explainer
SQL query explainer
Paste a query and read it clause by clause, in the order the database actually runs it — CTEs, joins, grouping, window functions and all.
What it explains
The order the database runs it
FROM and joins, then WHERE, GROUP BY, HAVING, SELECT, ORDER BY, LIMIT — not the order it is written.
Each CTE on its own
Every WITH step is explained separately, top to bottom, the way the main query reads them.
Joins and what they keep
Which rows an INNER, LEFT, RIGHT, FULL or CROSS join keeps, and the fan-out warning when a join can repeat rows.
Window functions
What OVER, PARTITION BY and the ORDER BY inside it do, and how ROW_NUMBER, RANK and DENSE_RANK differ on ties.
CASE, COALESCE, subqueries
Conditional values, NULL defaults, and when a subquery runs once per row.
It reads the SQL text — it does not connect to a database or see your data. A query can pass every check and still answer the wrong question, which is what a grader against real tables is for.
These are the mistakes interviews are built to catch.
SQL Quest grades your query against real tables and tells you which rows are wrong, then builds your practice around the skills you miss. Ten questions find the weakest one.
Questions
What order does SQL run a query in?
FROM and the joins first, then WHERE, GROUP BY, HAVING, then SELECT (including window functions), DISTINCT, ORDER BY and LIMIT. That is why a SELECT alias cannot be used in WHERE, and why a window function cannot be filtered in the same query that computes it.
Does the explainer send my query to an AI?
No. The explanation is produced in your browser from the structure of the query, so it works offline and nothing leaves the page.
Can it explain CTEs and window functions?
Yes. Each WITH step is explained on its own, and window functions get a note on what OVER, PARTITION BY and ORDER BY do, including how ROW_NUMBER, RANK and DENSE_RANK treat ties.