Drill 2 of 9 in Joining Tables
0

Joining Tables · INNER JOIN vs LEFT JOIN

2. Every user and their plan

Concept: INNER JOIN vs LEFT JOINshow

INNER JOIN keeps only rows that match in both tables. LEFT JOIN keeps every row from the left (first) table; when there's no match, the right table's columns come back as NULL.

Example (different data):

SELECT a.name, b.title
FROM authors a
LEFT JOIN books b ON b.author_id = a.id;

Your task

Growth wants to target free users with an upgrade campaign, so the report must include users who never subscribed.

Return username and plan for every user, with plan NULL when the user has no subscription. Sort 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).