LEFT JOIN keeps everyone
What you are building
The task in front of you: What does LEFT JOIN keep?.
The editor already holds a working starting point. Do not delete it and start again — read it, change one thing, run it, and watch which check moves. That loop is the whole method.
Why this matters
You are inside the section “Section 3 · Joins and subqueries” of the SQL & Databases track. Everything in this section builds towards the section project, and this task is one of the pieces that project leans on.
In real work nobody marks your code — it either runs or it does not, and someone is waiting for the result. The checks here are deliberately strict about output, because a program that prints the right thing in the wrong shape fails in the real world too.
The key idea
SQL describes the result you want, not the steps to get it. SELECT picks columns, FROM picks the table, and WHERE filters rows before they are returned.
Quotes matter: text needs single quotes, numbers do not. A column name in the wrong place is the most common reason a correct-looking query returns nothing.
Two mistakes to avoid
- Filtering with WHERE after a JOIN when you meant to filter before it — the rows you excluded still influenced the join.
- Writing SELECT * and then comparing text output. Ask for exactly the columns the task names, in the order it names them.
What the automatic checks look for
The right-hand column runs 1 check every time you press Run code. Nothing is hidden:
- The output has to contain “rows:[["Sara",11667],["S…”.
Task
What does LEFT JOIN keep?
The editor already contains a starting point. Change it until every check passes — the Next task button unlocks when it does.
What you start with
SELECT students.name, fees.amount FROM students LEFT JOIN fees ON fees.student_id = students.id;
The sample database
CREATE TABLE courses (id INTEGER PRIMARY KEY, title TEXT, monthly_fee INTEGER); CREATE TABLE students (id INTEGER PRIMARY KEY, name TEXT, city TEXT, course_id INTEGER, joined TEXT); CREATE TABLE fees (id INTEGER PRIMARY KEY, student_id INTEGER, month TEXT, amount INTEGER, paid INTEGER); INSERT INTO courses VALUES (1,'Web Design',9000),(2,'Python',11667),(3,'JavaScript',11667),(4,'AI & Prompt Engineering',15000); INSERT INTO students VALUES (1,'Sara','Faisalabad',2,'2026-01-12'), (2,'Ali','Faisalabad',1,'2026-01-20'), (3,'Hina','Jhumra',2,'2026-02-02'), (4,'Bilal','Faisalabad',4,'2026-02-15'), (5,'Ayesha','Sargodha',3,'2026-03-01'), (6,'Usman','Jhumra',1,'2026-03-11'), (7,'Zainab','Faisalabad',4,'2026-04-05'), (8,'Hamza','Faisalabad',3,'2026-04-19'); INSERT INTO fees VALUES (1,1,'2026-01',11667,1),(2,1,'2026-02',11667,1), (3,2,'2026-01',9000,1),(4,2,'2026-02',9000,0), (5,3,'2026-02',11667,1),(6,3,'2026-03',11667,0), (7,4,'2026-02',15000,1),(8,4,'2026-03',15000,1), (9,5,'2026-03',11667,0), (10,6,'2026-03',9000,1),(11,6,'2026-04',9000,0), (12,7,'2026-04',15000,0), (13,8,'2026-04',11667,1);
Run your code to see the output and the checks.
Submit your code to see results
Write your code in the middle column and press Run code.
Why this works
Checks on this task:
- Check 1
Stuck? The Hint button at the bottom nudges you one step without handing over the answer — that is on purpose: an exercise you copied teaches nothing.
Track progress
0 of 56 tasks complete
Next task unlocks when every check passes.
Sign in to keep your code and certificates.
Re-read the task: “What does LEFT JOIN…”. Write the SELECT and FROM first, run it, then add WHERE. Each clause you add should narrow the rows you already saw. The output has to contain “rows:[["Sara",11667],["S…”.
Still stuck? Re-read “What you are building” in the left column and change one line at a time. Press Run after every change.