- 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: Find the Bug
This SQL quiz shows queries with a comment saying what they were meant to do, and asks what they really return or what is wrong. The bugs are the ones that slip into real code and interviews, like operator precedence, join fan-out, integer division and subqueries that quietly match everything.
Sample question
Question 1 of 10The query below has a bug. What does it print?
CREATE TABLE products (name TEXT, category TEXT, price INTEGER);
INSERT INTO products VALUES
('pen', 'office', 2), ('desk', 'office', 300),
('tv', 'tech', 500), ('cable', 'tech', 5);
-- meant: cheap items (price < 10) in office or tech
SELECT COUNT(*) FROM products
WHERE category = 'office' OR category = 'tech' AND price < 10;
Show the answer
B. 3 AND binds tighter than OR, so this means office OR (tech AND price < 10): pen, desk and cable. Add parentheses, (category = 'office' OR category = 'tech') AND price < 10, or use category IN ('office', 'tech'), to get the intended 2.
What this quiz covers
- AND/OR precedence and date range edges
COUNT(*)withLEFT JOIN, and join fan-out inSUM- Integer division in percentages
- Ambiguous columns,
UNIONmismatches and quoting - Subqueries and window functions used in the wrong place
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.