- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
SQL Join Pitfalls Quiz
This SQL quiz collects the join mistakes that produce wrong numbers without any error. You will see a LEFT JOIN turned into an inner join by WHERE, totals multiplied by fan-out, NULL keys that never match and other traps that show up in real reports and interviews.
Sample question
Question 1 of 10The goal is every customer, with their big orders if any. What does this print?
CREATE TABLE customers (id INTEGER, name TEXT);
CREATE TABLE orders (id INTEGER, customer_id INTEGER, amount INTEGER);
INSERT INTO customers VALUES (1, 'Ann'), (2, 'Bob'), (3, 'Cy');
INSERT INTO orders VALUES (10, 1, 10), (11, 1, 50), (12, 3, 5);
SELECT c.name
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id
WHERE o.amount > 20
ORDER BY c.name;
Show the answer
A. Ann WHERE runs after the join, and for Bob o.amount is NULL, so NULL > 20 is not true and his row is dropped (Cy's 5 fails too). A condition on the right table in WHERE turns the left join into an inner join.
What this quiz covers
- Filtering a LEFT JOIN in
WHEREvs inON - Fan-out when joining two one-to-many tables
- Why NULL keys never match
- A later INNER JOIN undoing a LEFT JOIN
SUM(DISTINCT)and duplicate rows
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.