Bird
0
0

This query returns fewer rows than expected:

medium📝 Debug Q7 of 15
SQL - LEFT and RIGHT JOIN
This query returns fewer rows than expected:
SELECT C.Name, O.OrderID FROM Customers C LEFT JOIN Orders O ON C.ID = O.CustomerID AND O.Status = 'Completed';
What is the likely problem?
ALEFT JOIN does not support multiple conditions
BO.Status column does not exist
CCustomers table is empty
DThe condition on O.Status in ON clause filters out unmatched rows
Step-by-Step Solution
Solution:
  1. Step 1: Analyze ON clause with multiple conditions

    Adding O.Status = 'Completed' in ON filters matches to only completed orders.
  2. Step 2: Effect on LEFT JOIN

    Rows with no completed orders get NULLs, but unmatched rows still appear; fewer matches reduce joined rows.
  3. Final Answer:

    The condition on O.Status in ON clause filters out unmatched rows -> Option D
  4. Quick Check:

    ON clause conditions limit matches in LEFT JOIN [OK]
Quick Trick: Conditions in ON limit matches; use WHERE for filtering results [OK]
Common Mistakes:
MISTAKES
  • Thinking LEFT JOIN ignores ON conditions
  • Assuming multiple ON conditions cause errors
  • Confusing ON and WHERE clauses

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes