Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-- Write a query that returns -- countries where there are customers but not emp

ID: 3594753 • Letter: #

Question

-- Write a query that returns
-- countries where there are customers but not employees using EXIST. (instead of using IN)
-- Tables involved: TSQL2012 database, Customers and Employees tables

-sample query

SELECT DISTINCT country
FROM Sales.Customers
WHERE country NOT IN
(SELECT E.country FROM HR.Employees AS E);

-- Desired output:
country
---------------
Argentina
Austria
Belgium
Brazil
Canada
Denmark
Finland
France
Germany
Ireland
Italy
Mexico
Norway
Poland
Portugal
Spain
Sweden
Switzerland
Venezuela

(19 row(s) affected)

Explanation / Answer

Answer:

SELECT DISTINCT c.country
FROM Sales.Customers c
WHERE NOT EXISTS
(SELECT E.country FROM HR.Employees AS E where c.country = E.country);