Drill 3 of 9 in Joining Tables
0

Joining Tables · LEFT JOIN · IS NULL

3. Users who never subscribed

Concept: LEFT JOIN · IS NULLshow

To find rows with no match (an 'anti-join'), LEFT JOIN and keep the rows where the right side came back empty: WHERE right.id IS NULL. NULL never equals anything, so = NULL is always false.

Example (different data):

SELECT a.name
FROM authors a
LEFT JOIN books b ON b.author_id = a.id
WHERE b.id IS NULL;

Your task

Growth wants to email a discount to everyone who signed up but never subscribed to a plan.

Return the username of every user with no subscription, sorted by username.

Solution unlocks after 3 more tries

Starting Postgres in your browser…

query.sql
Output

Write a query and press Run Query (Ctrl/⌘ + Enter).