programming-examples/sql/Subqueries/17. Write a query to find all the salesmen who worked for only one customer.sql

10 lines
339 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*17. Write a query to find all the salesmen who worked for only one customer.*/
SELECT *
FROM salesman
WHERE salesman_id IN (
SELECT DISTINCT salesman_id
FROM customer a
WHERE NOT EXISTS (
SELECT * FROM customer b
WHERE a.salesman_id=b.salesman_id
AND a.cust_name<>b.cust_name));