CompTIA DataSys+ (DS0-001) — Question 8
A business analyst is using a client table and an invoice table to create a database view that shows clients who have not made purchases yet. Which of the following joins is most appropriate for the analyst to use to create this database view?
Answer options
- A. INNER JOIN ON Client.Key = Invoice.Key
- B. RIGHT JOIN ON Client.Key = Invoice.Key WHERE BY Client.Key IS NULL
- C. LEFT JOIN ON Client.Key = Invoice.Key
- D. LEFT JOIN ON Client.Key = Invoice.Key WHERE BY Invoice.Key IS NULL
Correct answer: D
Explanation
The correct choice is D, as using a LEFT JOIN on Client.Key with a condition of Invoice.Key being NULL effectively retrieves all clients who do not have corresponding entries in the invoice table. Option A is incorrect because an INNER JOIN would exclude clients with no purchases. Option B is not suitable as a RIGHT JOIN is not needed here, and it also incorrectly filters on Client.Key. Option C fails to filter for clients without purchases, as it would include clients who have made purchases as well.