The quick answer
Paste a query and the explainer splits it into clauses, explaining each in plain English in the order SQL actually runs: FROM and JOIN build the row set, WHERE filters rows, GROUP BY collapses them, HAVING filters groups, SELECT computes, ORDER BY sorts, LIMIT truncates. The explanation re-renders on every keystroke in your browser; the query never uploads.
The query someone left behind
Every team has one: it lives in a scheduled report, it is 47 lines long, it was written by an engineer who left in 2023, and someone asked you to change one number in it. Reading it top to bottom is the natural instinct and the wrong one, because SQL's written order is a lie about its execution order.
This page takes that query, pasted whole with comments and all, and hands back a plain-English walkthrough of every clause it recognizes, ordered the way the database actually processes them. It is deterministic narration, not a language model improvising: the same query always produces the same explanation, and nothing in the explanation can invent tables or columns the query does not mention.
The audience is broader than "junior developers learning SQL," though it is happily that too. It is anyone who needs to answer, quickly and with confidence, the question what does this query actually do: reviewers checking a pull request, analysts deciphering a dashboard's source query, support engineers staring at something a ticket pasted in at 4:55 p.m.
From query text to an explanation you can check
The pipeline has two stages and no magic. The text is scanned for the clauses it contains, and each clause that appears gets an explanation card, with the whole list sitting under a header that states the logical execution order. Nothing is tokenized into a tree; the clause keyword in place is the unit of analysis, which is exactly why the output is instant and re-renders on every keystroke.
Nothing in that pipeline consults a database or sends your text anywhere. The explanations are fixed, structural sentences: what INNER versus LEFT join does to rows, why an aggregate condition belongs in HAVING, which columns are safe to sort by. It has no opinions about your data because it cannot see your data, and that boundary is what makes its output trustworthy: no hallucinated tables, no confident claims about rows it never counted.
Some of the classic gotcha teaching is baked into the clause cards themselves: the WHERE card states that aggregate functions are not allowed there, the ORDER BY card warns that only SELECTed columns are safe to sort by in strict SQL, and the SELECT card notes aggregate functions whenever the select list contains parentheses. Those are fixed sentences printed on every explanation, so they cost nothing and never misfire.
Explaining a query in four moves
Paste the query
Any SELECT, plus WITH/INSERT/UPDATE/DELETE if that is what you were handed; the textarea takes the whole statement, comments included.
Watch the cards update live
The explanation recomputes on every keystroke, so edits to the query show up in the cards immediately.
Read the walkthrough
Each clause gets a card with a plain-English sentence; the SELECT card quotes the first 80 characters of your select list, so you can map the card back to your text.
Keep the logical order in mind
The page states the execution order FROM → JOIN → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT; reasoning in that order, as the tool's own note puts it, explains 95% of query bugs.
The whole cycle is instant on any realistic query. The bottleneck is human: reading a correct explanation of a five-table join still takes the time it takes.
Where structure lives in a query
Structure, not character order, is what carries meaning in SQL. In the expression a = 1 AND (b = 2 OR c = 3), the parentheses decide that the OR is evaluated before the AND combines its result with a = 1; remove them and the meaning changes. Reading a query well means tracking that structure, and the two facts that carry most of it are what each clause does and when it runs.
This explainer deliberately works at the clause level rather than pretending to a full parse tree. The cards name the clause and state what that stage does; the execution-order table below and the worked example carry the rest of the load, because for everyday reading those facts are the ones that matter.
The order SQL actually runs in
The single most useful fact this tool teaches is the gap between written order and execution order. SQL is written SELECT-first and executed SELECT-almost-last: FROM and JOIN build the row set, WHERE filters it, GROUP BY collapses it, HAVING filters the groups, and only then does the SELECT list run.
| Runs at | Clause | Written at position | What happens |
|---|---|---|---|
| 1 | FROM / JOIN | 3rd–4th | Tables are combined into the working row set |
| 2 | WHERE | 5th | Rows failing the predicate are dropped, one row at a time |
| 3 | GROUP BY | 6th | Surviving rows collapse into groups per distinct key |
| 4 | HAVING | 7th | Groups failing the aggregate predicate are dropped |
| 5 | SELECT | 1st | Expressions and aggregates are computed, per group if grouped |
| 6 | DISTINCT | after SELECT list | Duplicate result rows are removed |
| 7 | ORDER BY | 8th | Result rows (or groups) are sorted |
| 8 | LIMIT / OFFSET | last | The sorted result is truncated |
The pipeline explains the classic alias trap with no memorization required. `WHERE revenue_cents > 1000` fails or behaves oddly because WHERE runs at step 2 while the alias `revenue_cents` is invented at step 5, and the name does not exist yet, like referring to a variable before its line of code executes. `ORDER BY revenue_cents` works because sorting happens at step 7, comfortably after the alias was defined. Engines add their own wrinkles; some let HAVING see aliases, and some ORDER BY corner cases differ, which is why the logical order this page teaches is the baseline rather than a promise about every engine's exact behavior.
It also explains why aggregates cannot live in WHERE. `WHERE COUNT(*) > 3` is a category error: COUNT needs groups to count, groups do not exist until step 3, and WHERE is stuck back at step 2 with individual rows. The correct home for that condition is HAVING, one pipeline stage later. The WHERE card states the rule in those terms, which is more useful than the error message most engines produce.
A full query, narrated end to end
Here is a revenue-reporting query in the shape you would actually meet in a codebase: two tables, two filters, grouping, a group filter, sort and truncation. Paste it in and every clause gets its card; the reading below walks the same query in execution order, which is the order worth learning.
SELECT c.full_name,
COUNT(o.id) AS order_count,
SUM(o.total_cents) AS revenue_cents
FROM customers c
JOIN orders o ON o.customer_id = c.id
WHERE c.country = 'US'
AND o.placed_at >= '2026-01-01'
GROUP BY c.id, c.full_name
HAVING COUNT(o.id) >= 3
ORDER BY revenue_cents DESC
LIMIT 5;FROM customers (alias c)
-> the driving table; 1,200 rows in this mental model
JOIN orders o ON o.customer_id = c.id
-> inner join: keep only orders with a matching customer row
(and only customers with at least one order)
WHERE c.country = 'US'
-> filter rows BEFORE grouping; drops non-US customers
WHERE o.placed_at >= '2026-01-01'
-> rows outside the date range leave now, not later
GROUP BY c.id, c.full_name
-> collapse surviving rows into one group per customer
HAVING COUNT(o.id) >= 3
-> group filter AFTER collapsing; keeps 3+ order customers only
SELECT c.full_name, COUNT(o.id), SUM(o.total_cents)
-> computed per group, not per row
ORDER BY revenue_cents DESC
-> sorts the ~87 surviving groups, highest revenue first
LIMIT 5
-> last word, last effect: keep the top 5 groupsNow the same query with numbers, because row counts are where execution order stops being academic. Suppose customers holds 1,200 rows and orders holds 14,800:
| Stage | Rows in | Rows out | Why |
|---|---|---|---|
| FROM + JOIN | 1,200 + 14,800 | 14,800 | Inner join keeps one row per order that matches a customer |
| WHERE (country + date) | 14,800 | 4,300 | Both predicates applied per row, before any grouping |
| GROUP BY customer | 4,300 | 610 groups | One group per customer who survived the filters |
| HAVING count >= 3 | 610 | 87 | Groups with 1–2 orders are dropped here, not earlier |
| SELECT + ORDER BY + LIMIT | 87 | 5 | Aggregates computed per group, sorted, truncated |
Input
HAVING COUNT(o.id) >= 3 (aggregate filter, runs on groups)
Output
WHERE COUNT(o.id) >= 3 → rejected by every engine: no groups exist yet at that stage
Input
JOIN orders o ON o.customer_id = c.id AND o.placed_at >= '2026-01-01' with an INNER JOIN
Output
Same result as WHERE for inner joins; with LEFT JOIN it would change meaning: unmatched customers survive with NULL aggregates, a classic silent bug
Those two examples compress most of what goes wrong in real reporting queries. Filters migrate between stages because the text order misleads the author; conditions drift between ON and WHERE because for inner joins the difference is invisible right up until someone changes the join type. The execution-order reading above is what makes the migration visible before it costs you.
What the clause cards say
Every card is a fixed sentence keyed to a clause, and the set is small enough to print in full. This is the complete vocabulary, which is also the honest scope statement of the tool:
- SELECT: chooses the output columns; when the select list contains parentheses, the card notes that aggregate functions (COUNT/SUM/AVG/MIN/MAX) collapse groups into single values.
- FROM: sets the working tables and how rows from each combine (comma-join, JOIN … ON).
- JOIN … ON: pairs rows from the joined tables where the ON condition holds; INNER keeps matches only, LEFT keeps every left row.
- WHERE: filters individual rows before grouping; aggregate functions are not allowed here, that is HAVING's job.
- GROUP BY: collapses rows into one per distinct combination of the listed columns.
- HAVING: filters the groups after aggregation, which is where SUM(...) > 500 belongs.
- ORDER BY: sorts the final rows; in strict SQL only SELECTed columns are safe to sort by.
- LIMIT: truncates the result set to the first N rows after sorting.
- WITH, INSERT, UPDATE, DELETE: leading cards for CTEs and the three DML statements, including the warning that an UPDATE without WHERE rewrites the whole table.
Two consequences follow from that vocabulary. Subqueries, window functions, UNION and CASE get no card of their own: they ride along as text inside the clauses the scan does see, so a query built around OVER partitions still gets a correct clause-by-clause reading, just not a window-function tutorial. And because the cards key on keywords in place, the scan validates nothing; a syntactically broken query still produces cards for whichever clauses it happens to contain, which is why syntax checking is a separate page's job, the SQL Syntax Validator.
What it cannot tell you
An honest explainer states its blind spots. This one has three:
- No schema knowledge. The JOIN card explains what the ON condition does to row pairing, but whether that join produces 1 row or 14,800 depends on cardinalities it cannot see, and it says nothing about whether `customer_id` is indexed.
- No cost model. Nothing here approximates runtime. Whether a function wrapped around an indexed column disables index use in your database is EXPLAIN's business.
- No semantics beyond the standard. Views, stored procedures, and application-side logic are invisible. A query against a view called `active_users` is narrated as a plain table reference; the view's own definition would need its own pasting.
The boundary is also the privacy story, stated technically: because the tool works purely on text, there is nothing it needs from your infrastructure, and nothing your infrastructure needs to expose to it.
Explainer versus EXPLAIN versus a chatbot
| Approach | Understands structure | Knows your data | Privacy | What it is for |
|---|---|---|---|---|
| This explainer | Yes, clause scan and narration | No | Query never leaves the tab | Learning what a query does |
| Database EXPLAIN | Yes, the planner's actual physical plan | Yes, statistics, indexes, row estimates | Needs a live connection | Tuning how a query runs |
| AI chat assistants | Often yes, sometimes invented | Only what you paste | Query and schema details go to a server | Conversational debugging, at a price |
| Reading the docs | You build the model yourself | n/a | Total | The deep path; slowest, most durable |
EXPLAIN and this tool are complements, not competitors: the classic pairing is explain-for-meaning first, EXPLAIN-for-cost second, because tuning a query you misread means tuning the wrong thing. The chatbot comparison is fairer than it sounds: conversational explainers are genuinely flexible, but they send your production SQL to someone else's server and occasionally describe a join that is not in your query with total confidence. A deterministic narrator that cannot hallucinate is the right default when the query is proprietary or the reader is still learning to trust their own reading.
Reading the docs remains the undefeated long game. This page exists to make that path shorter, not to replace it: the narration gives you the vocabulary, and the manual gives you the fine print.
Queries stay off the network
Production SQL is sensitive in ways people forget: table names describe the business, literal values in WHERE clauses are sometimes customer IDs, and comment blocks have a long tradition of containing things HR should never see. The scan and the narration run entirely in the page, so the query text moves from your clipboard to your browser and stops there.
Deterministic clause scanning is what makes that architecture possible at zero cost: no model weights to host, no inference to bill, just a keyword scan that a 2015 laptop finishes between keystrokes. The page loads once from the CDN and then never needs the network again, which conveniently also describes its behavior on a train, a plane, or a locked-down corporate laptop.
If the query came from a system with a compliance story attached, the same property applies with emphasis: there is no retention question to answer, because there is no transmission to retain.
Frequently asked questions
Which SQL dialects does the explainer understand?
The clause scan is dialect-agnostic: it recognizes SELECT, FROM, JOIN … ON, WHERE, GROUP BY, HAVING, ORDER BY and LIMIT wherever those keywords appear, from MySQL to PostgreSQL to SQLite, and gives WITH, INSERT, UPDATE and DELETE statements their own cards. What it does not do is dialect validation, which is the SQL Syntax Validator page's job.
Does it need a database connection or my data?
No. The explainer is purely syntactic: it reads the query text, scans it for its clauses, and narrates the structure. It never sees your tables, your row counts, or your indexes. Everything it says is derived from the query alone, which is exactly why it can run with zero setup.
Can it tell me why my query is slow?
It tells you what the query does clause by clause, which is the first half of any performance investigation, but it has no cost model and sees no data. Actual speed depends on your data volume, statistics, and indexes, which requires EXPLAIN against the live database. Use the explainer to understand, use EXPLAIN to tune.
Why can I use a SELECT alias in ORDER BY but not in WHERE?
Because of logical execution order. WHERE runs before SELECT, so the alias does not exist yet when the filter is evaluated; ORDER BY runs after SELECT, so the alias is already defined. The ORDER BY card's standing note, that in strict SQL only SELECTed columns are safe to sort by, is this same rule printed where you meet it.
Does it store or transmit my queries?
No. The scan and narration happen entirely in your browser. Production queries embed table names, business logic, and occasionally literal customer values, so this tool was deliberately built with no network hop: the text you paste stays in the tab.
Will it rewrite or improve my query for me?
It explains; it does not edit. The clause cards annotate the query's structure, and the UPDATE card warns that omitting WHERE rewrites the whole table, but the query text itself is never modified. You decide what to change, which is how it should be when the tool has no idea what correct means for your data.
Sources and further reading
The references below are the primary documentation for the execution-order claims on this page: PostgreSQL's query-processing and SELECT references. For running queries without a database, the SQL on CSV tool covers the next step of the loop.
Sources and further reading
- PostgreSQL — Queries: table expressions, WHERE, GROUP BY, HAVING(postgresql.org)
- PostgreSQL — SELECT statement reference(postgresql.org)
We cite primary sources (standards bodies, government agencies, official documentation) wherever they exist so you can verify every number on this page yourself.