35. Customers Without Orders
MediumJoinsanti-joinNOT EXISTSLEFT JOIN ... IS NULL
An anti-join returns rows from one table that have no match in another — here, customers who never placed an order.
Task: return the name of every customer who has zero rows in orders.
There are two idiomatic ways to write an anti-join, both shown in the solutions: NOT EXISTS, and a LEFT JOIN that keeps only the rows where the right side came back NULL.
Output column: name. Order by name ascending.
Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…
This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases — 5test cases in all. A sloppy query that only fits the example won't pass.
SQL· SQLite · runs in your browser
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.