programming-examples/sql/Subqueries/16. Write a query to find the salesmen who have multiple customers.sql
2019-11-18 14:05:53 +01:00

11 lines
335 B
SQL

/*16. Write a query to find the salesmen who have multiple customers.*/
SELECT *
FROM salesman
WHERE salesman_id IN (
SELECT DISTINCT salesman_id
FROM customer a
WHERE EXISTS (
SELECT *
FROM customer b
WHERE b.salesman_id=a.salesman_id
AND b.cust_name<>a.cust_name));