Table Customer(id) has rows 1, 2, 3. Table Orders(cust_id) has rows 1, 1, 3. SELECT COUNT(*) FROM Customer c WHERE NOT EXISTS (SELECT 1 FROM Orders o WHERE o.cust_id = c.id); What is the result?
Correct answer C. 1
Explanation
EXISTS is true if the subquery returns at least one row; what it selects (here the constant 1) does not matter. For each customer the correlated subquery looks for that customer's orders. Customers 1 and 3 have orders, so NOT EXISTS is false for them. Only customer 2 has none, giving a count of 1. This is the standard pattern for finding rows with no match.
Answer checked How we write and check questions
Discussion