Querying Data with Transact-SQL — Question 145

Note: This question is part of a series of questions that use the same or similar answer choices. An answer choice may be correct for more than one question in the series. Each question is independent of the other questions in this series. Information and details provided in a question apply only to that question.
You have a database that contains several connected tables. The tables contain sales data for customers in the United States only.
All the sales data is stored in a table named table1. You have a table named table2 that contains city names.
You need to create a query that lists only the cities that have no sales.
Which statement clause should you add to the query?

Answer options

Correct answer: D

Explanation

The correct answer is D, LEFT JOIN, because it allows you to include all records from table2 (cities) and only the matching records from table1 (sales data). This way, cities with no sales will still be listed with NULL values from the sales table. The other options do not serve the purpose of including all cities while filtering for those without sales data.