SQL Subquery Exercises: Display the rows of all salesmen who have customers with more than one orders
SQL SUBQUERY: Exercise-18 with Solution
18. Write a query that extract the rows of all salesmen who have customers with more than one orders.
Sample table: Salesman
Sample table: Orders
Sample table: Customer
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));
salesman_id name city commission 5001 James Hoog New York 0.15 5002 Nail Knite Paris 0.13 5003 Lauson Hen San Jose 0.12
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?