
Answer-first summary for fast verification
Answer: Left Join
The question requires identifying both customers who have placed orders in the past year AND those who have not, using a single join statement. A Left Join (B) returns all customers from the customers table along with their order information if they placed an order (matching records) and NULL values for customers without orders (non-matching records). This allows the analyst to distinguish between both groups in one query. Left Semi Join (A) only returns customers who have placed orders, excluding those without orders. Left Anti Join (D) only returns customers without orders, excluding those with orders. Middle Join (C) is not a standard SQL join type. The community discussion shows 100% consensus for A, but this appears to be incorrect based on the question requirements - A only solves half the problem while B solves both parts simultaneously.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
A data analyst needs to identify which customers have placed an order in the past year and which have not, using a single statement that joins a unique customers table and an orders table.
Which type of join should be used?
A
Left Semi Join
B
Left Join
C
Middle Join
D
Left Anti Join
No comments yet.