Bird
0
0

What will be the result of this query?

medium📝 query result Q5 of 15
PostgreSQL - Joins in PostgreSQL
What will be the result of this query?
SELECT * FROM products LEFT JOIN sales ON products.id = sales.product_id WHERE sales.sale_date IS NULL;
AAll products with their sales records
BSyntax error due to WHERE clause
COnly sales records without matching products
DProducts that have no sales records
Step-by-Step Solution
Solution:
  1. Step 1: Understand LEFT JOIN with WHERE condition

    LEFT JOIN returns all products and matching sales; WHERE filters rows where sales.sale_date is NULL.
  2. Step 2: Interpret NULL in sales.sale_date

    NULL means no matching sales record exists for those products.
  3. Final Answer:

    Products that have no sales records -> Option D
  4. Quick Check:

    LEFT JOIN + IS NULL filters unmatched left rows [OK]
Quick Trick: Use LEFT JOIN with IS NULL to find unmatched rows [OK]
Common Mistakes:
  • Thinking it returns all products with sales
  • Confusing NULL with empty string
  • Assuming syntax error due to WHERE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes