SQL query explainer
Paste a query and find out what each part does and how its clauses relate to each other.
Your SQL is processed in this browser. We do not send the content of your queries to AprenderSQL.es.
The query you want to understand
One SELECT statement at a timeExplanation
Logical order for learning, not the engine's physical planExplain a query to see the summary, the steps and related concepts here.
Examples to try
What this version can explain
It focuses on SELECT: filters, aggregates, JOINs, subqueries, CTEs, UNION, CASE and window functions supported by the teaching engine. INSERT, UPDATE, DELETE and DDL can be run in the SQL editor, but are not explained here yet.
How to read the explanation it produces
The explainer is designed for learning: it identifies the recognisable parts of a SELECT query and presents them in an order that helps you reason about the data. It does not try to guess the internal plan that PostgreSQL, MySQL, SQL Server or SQLite would choose.
Sources and joins
It starts with FROM and the JOINs, because that is where the rows and tables available to the rest of the query are defined.
Filters and groups
Then it separates WHERE, GROUP BY and HAVING. This separation helps you avoid a common mistake: trying to filter an aggregated result before it exists.
Result and order
SELECT builds the final columns; ORDER BY and LIMIT determine their presentation and how much is returned. Window functions are explained separately from ordinary grouping.
Example of the reasoning
In SELECT category_id, COUNT(*) FROM products WHERE stock > 0 GROUP BY category_id HAVING COUNT(*) > 2;, the products in stock are kept first, then grouped by category, the count is calculated, and finally the groups with two products or fewer are discarded.
That mental order explains why WHERE COUNT(*) > 2 would not be the right form: WHERE is evaluated on the original rows, while the count only appears once rows are grouped. The explainer links concepts like this to the matching lessons, so you can dig into the cause rather than memorising a fix.
Limits of the tool
The analysis is deliberately a teaching tool. It can help you recognise SELECT, filters, JOINs, aggregates, subqueries, CTEs, UNION, CASE and the window functions covered by the course, but it does not replace a full parser for your database's dialect. Nor does it run EXPLAIN, estimate costs or know the indexes, constraints or statistics of an external database.
If a query depends on an engine-specific feature, use the explanation as a general map and then confirm the syntax in that engine's documentation. To check the result against data, open the query in the site's SQL editor.