SQL Subquery Exercises: Display the names and numbers of all salesmen who had more than one customer
SQL SUBQUERY: Exercise-11 with Solution
11. Write a query to find the name and numbers of all salesmen who had more than one customer.
Sample table: customer
Sample table: salesman
SELECT salesman_id,name FROM salesman a WHERE 1 < (SELECT COUNT(*) FROM customer WHERE salesman_id=a.salesman_id);
Output of the Query:
salesman_id name 5001 James Hoog 5002 Nail Knite
Contribute your code and comments through Disqus.
Previous: Write a query to display all the customers with orders issued on date 17th August, 2012.
Next: Write a query to find all orders with order amounts which are above-average amounts for their customers.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework