SQL Query Execution

Type SQL and watch rows flow through the execution pipeline — parse, filter, sort, limit.

Table: employees (id INT, name STRING, age INT, dept STRING, salary INT) — 12 rows
Ctrl+Enter
Click Execute or press Ctrl+Enter to run a query.

Full SQL support via AlaSQL. Try SELECT, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT, COUNT, SUM, AVG, MIN, MAX, DISTINCT, and more.

What the SQL execution visualizer shows

Type a query and watch rows flow through the execution pipeline — parsed, filtered by WHERE, sorted by ORDER BY, and trimmed by LIMIT. Seeing rows enter and drop out at each stage explains what the database actually does with your SQL, not just what you wrote.

How SQL execution order works

SQL is written SELECT … FROM … WHERE … ORDER BY, but it runs in a different order: FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. That logical order explains a lot of "gotchas" — for example, why a column alias you create in SELECT can't be used in WHERE (the filter runs first), but can be used in ORDER BY (which runs later).

Why it matters

Understanding execution order is the difference between guessing at SQL and reasoning about it — it drives both correctness and performance (filter early, sort late). Keep the syntax close with the SQL cheatsheet.

Frequently asked questions

Why can't I use a SELECT alias in WHERE?

Because WHERE runs before SELECT in the logical order, the alias doesn't exist yet. Use the full expression in WHERE, or filter in a subquery.

What's the difference between WHERE and HAVING?

WHERE filters individual rows before grouping; HAVING filters groups after GROUP BY (so it can use aggregates like COUNT(*)).

Does LIMIT make my query faster?

It can — the database can stop early once it has enough rows — but only if it doesn't first have to sort or aggregate the entire result set.