CBSE Class 12 Informatics Practices Question 81 of 91

JOINS and SET Operations — Question 17

Back to all questions
17
Question

Question 17

Consider following tables to answer below question :

Salesman (salesman_id, name, city, commission ) and

Customer (customer_id, cust_name, city, grade, salesman_id )

Write an SQL query to list all the salesmen who do not have customers in 'DELHI' and 'JAMMU'.

Answer
SELECT s.name
FROM Salesman s
WHERE s.salesman_id NOT IN (
  SELECT DISTINCT c.salesman_id
  FROM Customer c
  WHERE c.city IN ('DELHI', 'JAMMU')
);