SQL QuestSQL Interview Questions › Joins

LEFT JOIN: Watch the NULLs Appear

EasyFreeQuerying BasicsJoinsNULL Handling

Support wants every customer listed with their orders — including the customers who have never ordered anything.

Use a LEFT JOIN from customers to orders and show name, membership, product, total. Order by name, then order_id.

The new idea, and it is the whole point of LEFT JOIN: rows on the left survive even when nothing on the right matches. Those rows come back with NULL in every column that came from orders.

Don't filter the NULLs out. Look at them. Scroll to Amy Taylor — she's there, with product and total empty. Six customers look like that. Change LEFT JOIN to JOIN and those six vanish without a word of warning; that silent disappearance is the single most common way a report ends up quietly wrong.

Solve it in the browser editor →

Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect".

Schema

customers

customer_idnameemailsignup_datemembershiptotal_orders
1John Smithjohn.smith@email.com2023-01-15Gold15
2Emma Wilsonemma.wilson@email.com2023-03-20Silver8
3Michael Brownmichael.brown@email.com2023-02-10Gold12

orders

order_idcustomer_idproductcategoryquantitypricetotalorder_datecountrystatus
11Laptop ProElectronics11299.991299.992024-01-15USAcompleted
22Wireless MouseElectronics249.9999.982024-01-16Canadacompleted
33Office ChairFurniture1349.99349.992024-01-17USAcompleted

Expected output: 46 rows — 40 real orders plus 6 customers carrying NULLs

Hint

The hint for this one spells out most of the query, so it stays in the editor. Reach for SELECT, LEFT JOIN, NULL Handling, and open the hint there if you stall.

Concepts

SELECT LEFT JOIN NULL Handling

Practise the topic: SQL practice questions · JOIN practice · NULL handling practice

In these company practice sets

Stripe · DoorDash · TikTok · LinkedIn

A SQL Quest challenge matched to patterns reported for these companies — not a question any of them has published.

Related questions

Your First JOINEasy · FreeJOIN with a FilterEasy · FreeCounting Across a JOINEasy · FreeTransaction Share by Merchant CategoryEasy · FreeSignup-Month Cohort SpendEasy · FreeCard Spend by CountryEasy · Free

Where would this cost you points in an interview?

Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.

Take the readiness test