DEV/SQL

SQL Query Explainer

Paste any SQL query and get a plain-English explanation of every clause: SELECT, JOIN, WHERE, GROUP BY, HAVING, and more.

SELECTu.id, u.name, COUNT(o.id) AS orders
Return these columns from the result: u.id, u.name, COUNT(o.id) AS orders.
FROMusers u
Read data from users u as the base of the query.
LEFT JOINorders o ON o.user_id = u.id
Keep every row from the left table and attach matching rows from orders o where o.user_id = u.id. Missing matches become NULL.
WHEREu.created_at > '2024-01-01'
Filter rows: keep only rows where u.created_at > '2024-01-01' is true.
GROUP BYu.id, u.name
Collapse rows into groups that share the same u.id, u.name. Aggregates (COUNT/SUM/AVG) run per group.
HAVINGCOUNT(o.id) > 3
Filter the grouped rows: only keep groups where COUNT(o.id) > 3.
ORDER BYorders DESC
Sort the results by orders DESC.
LIMIT50
Return at most 50 row(s).

Related tools

All →