SQL Explainer

Paste any SELECT query and get a clause-by-clause plain-English breakdown — for when you're reading SQL you didn't write.

SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY LIMIT
Try:

SQL clause reference

Clauses, in order

WITHdefine named subqueries (CTEs) used below
SELECTchoose which columns to return
FROMwhich table to read from
JOINmerge rows from another table
WHEREfilter rows before grouping
GROUP BYgroup rows with equal values together
HAVINGfilter groups after aggregation
ORDER BYsort the result rows
LIMITcap the number of rows returned

JOIN types

INNER JOINonly rows that match in both tables
LEFT JOINall left rows + matched right (null if none)
RIGHT JOINall right rows + matched left (null if none)
FULL JOINall rows from both tables (null where no match)
CROSS JOINevery combination of left × right rows

Aggregate functions

COUNT(*)count all rows in the group
COUNT(col)count non-null values of col
SUM(col)add up all values
AVG(col)arithmetic mean of values
MAX(col)largest value in the group
MIN(col)smallest value in the group

Common operators

= / != / <>equals / not equals
> / < / >= / <=numeric comparisons
IS NULLvalue is missing / not set
IN (...)value appears in a list
LIKE 'x%'text matches a pattern (% = anything)
BETWEEN a AND bvalue is within range [a, b]