SQL exercise · about 5 minutes · free
LEFT JOIN: Don't Lose the Rookie
A new player has no matches yet. An INNER JOIN silently drops them from your report. A LEFT JOIN keeps them.
LEFT JOIN keeps every row from the left table, filling missing right-side values with NULL. COUNT(column) ignores NULLs, so players with no matches count as 0.
🌍 Real-life story
Real-life story: "customers with zero orders" vanishing from reports is a classic bug. Interviewers test it constantly.Your quest: Show every player's
name and number of matches as matches_played, including players with 0.Database:
players(id, name, class, level, country) · matches(id, player_id, map, kills, deaths, score) · orders(id, player_id, order_date, item, amount) · app_events(user_id, event, day) · employees(id, name, dept, salary, manager_id, hire_date) · logins(user_id, day) · payment_events(payment_id, user_id, amount, status, updated_at)Try it now Runs in your browser. No sign-in needed. Ctrl+Enter to run.
Hint
FROM players p LEFT JOIN matches m ON m.player_id = p.id GROUP BY p.name, counting m.id (not *).Output appears here.