SQL Subquery Exercises: Find all orders attributed to a salesman in New York
SQL SUBQUERY: Exercise-5 with Solution
5. Write a query to find all orders attributed to a salesman in New york.
Sample table: Salesman
Sample table: Orders
SELECT * FROM orders WHERE salesman_id IN (SELECT salesman_id FROM salesman WHERE city ='New York');
Output of the Query:
ord_no purch_amt ord_date customer_id salesman_id 70002 65.26 2012-10-05 3002 5001 70005 2400.60 2012-07-27 3007 5001 70008 5760.00 2012-09-10 3002 5001 70013 3045.60 2012-04-25 3002 5001
Contribute your code and comments through Disqus.
Previous: Write a query to display all the orders which values are greater than the average order value for 10th October 2012.
Next: Write a query to display the commission of all the salesmen servicing customers in Paris.
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