programming-examples/sql/Subqueries/18. Write a query that extract the rows of all salesmen who have customers with more than one orders.sql

11 lines
474 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*18. Write a query that extract the rows of all salesmen who have customers with more than one orders.*/
SELECT *
FROM salesman a
WHERE EXISTS
(SELECT * FROM customer b
WHERE a.salesman_id=b.salesman_id
AND 1<
(SELECT COUNT (*)
FROM orders
WHERE orders.customer_id =
b.customer_id));