Bird
0
0

You want to find all customers and their orders, including customers without orders and orders without customers. You write:

hard📝 Application Q9 of 15
SQL - Advanced Joins
You want to find all customers and their orders, including customers without orders and orders without customers. You write:
SELECT C.CustomerID, O.OrderID FROM Customers C FULL OUTER JOIN Orders O ON C.CustomerID = O.CustomerID WHERE O.OrderDate > '2023-01-01';

Why might this query exclude some customers without orders?
AThe query syntax is invalid for FULL OUTER JOIN.
BFULL OUTER JOIN does not include unmatched rows.
CThe ON condition is incorrect and causes no matches.
DThe WHERE clause filters out rows where O.OrderDate is NULL, removing customers without orders.
Step-by-Step Solution
Solution:
  1. Step 1: Understand WHERE clause effect after FULL OUTER JOIN

    WHERE filters rows after join, so rows with NULL in O.OrderDate (orders missing) are excluded.
  2. Step 2: Impact on customers without orders

    Customers without orders have NULL in O.OrderDate, so filtered out.
  3. Final Answer:

    The WHERE clause filters out rows where O.OrderDate is NULL, removing customers without orders. -> Option D
  4. Quick Check:

    WHERE filters after join, can exclude NULLs = D [OK]
Quick Trick: Use WHERE carefully; consider moving conditions to ON clause [OK]
Common Mistakes:
MISTAKES
  • Assuming FULL OUTER JOIN ignores WHERE
  • Not handling NULLs in WHERE filters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes