SQL Exercises with Solution - VIEW
SQL [16 exercises with solution]
1. Write a query to create a view for those salesmen belongs to the city New York.
Sample table: salesman
2. Write a query to create a view for all salesmen with columns salesman_id, name, and city.
Sample table: salesman
3. Write a query to find the salesmen of the city New York who achieved the commission more than 13%.
Sample table: salesman
4. Write a query to create a view to getting a count of how many customers we have at each level of a grade.
Sample table: customer
5. Write a query to create a view to keeping track the number of customers ordering, number of salesmen attached, average amount of orders and the total amount of orders in a day.
Sample table : orders
6. Write a query to create a view that shows for each order the salesman and customer by name.
Sample table: salesman
Sample table: customer
Sample table: orders
7. Write a query to create a view that finds the salesman who has the customer with the highest order of a day.
Sample table: salesman
Sample table: orders
8. Write a query to create a view that finds the salesman who has the customer with the highest order at least 3 times on a day.
Sample table: customer
Sample table: elitsalesman
9. Write a query to create a view that shows all of the customers who have the highest grade.
Sample table: customer
10. Write a query to create a view that shows the number of the salesman in each city.
Sample table: salesman
11. Write a query to create a view that shows the average and total orders for each salesman after his or her name. (Assume all names are unique)
Sample table: salesman
Sample table: orders
12. Write a query to create a view that shows each salesman with more than one customers.
Sample table: salesman
Sample table: customer
13. Write a query to create a view that shows all matches of customers with salesman such that at least one customer in the city of customer served by a salesman in the city of the salesman.
Sample table: salesman
Sample table: customer
14. Write a query to create a view that shows the number of orders in each day.
Sample table: orders
15. Write a query to create a view that finds the salesmen who issued orders on October 10th, 2012.
Sample table: salesman
Sample table: orders
16. Write a query to create a view that finds the salesmen who issued orders on either August 17th, 2012 or October 10th, 2012.
Sample table: orders
Query visualizations are generated using Postgres Explain Visualizer (pev)
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- 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
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework