SQLRepPath
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
00/60 solved

Intermediate Joins · INNER JOIN vs LEFT JOIN

12. 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).