SQL Exercises, Practice, Solution - UNION
SQL UNION [9 exercises with solution]
[An editor is available at the bottom of the page to write and execute the scripts.]
1. Write a query to display all salesmen and customer located in London. Go to the editor
Sample table: Salesman
Sample table: Customer
2. Write a query to display distinct salesman and their cities. Go to the editor
Sample table: Salesman
Sample table: Customer
3. Write a query to display all the salesmen and customer involved in this inventory management system. Go to the editor
Sample table: orders
Sample table: customer
4. Write a query to make a report of which salesman produce the largest and smallest orders on each date. Go to the editor
Sample table: Salesman
Sample table: Orders
5. Write a query to make a report of which salesman produce the largest and smallest orders on each date and arranged the orders number in smallest to the largest number. Go to the editor
Sample table: Salesman
Sample table: Orders
6. Write a query to list all the salesmen, and indicate those who do not have customers in their cities, as well as whose who do. Go to the editor
Sample table: Salesman
Sample table: Customer
7. Write a query to that appends strings to the selected fields, indicating whether or not a specified salesman was matched to a customer in his city. Go to the editor
Sample table: Salesman
Sample table: Customer
8. Create a union of two queries that shows the names, cities, and ratings of all customers. Those with a rating of 200 or greater will also have the words "High Rating", while the others will have the words "Low Rating".
Sample table: Customer
9. Write a command that produces the name and number of each salesman and each customer with more than one current order. Put the results in alphabetical order.
Sample table: Customer
Sample table: salesman
Sample table: orders
More to Come !
Query visualizations are generated using Postgres Explain Visualizer (pev)
Practice Online
SQL: Interview question/Tips of the Day
DML: Data Manipulation Language
DML contains statements to
- Insert data
- Delete data
- Change data
insert, delete, update
- 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