← Back ← Correlated subquery JOIN + SUM →

EXCEPT & INTERSECT

Set operations on two query results — anti-join vs overlap

SQL drill • Set operators

Two single-column queries of customer_id: A = customers who bought SUVs, B = customers who bought sedans. Use EXCEPT for “SUV but never sedan” and INTERSECT for “bought both body styles.” SQL Server / Oracle often spell EXCEPT as MINUS.

Vocab
EXCEPT = A − B  ·  INTERSECT = A ∩ B
Step 0/6Line
Venn intuition
Press Step or Play.
Ready
Column counts and types must line up between the two SELECTs.