w3resource logo


SQL exercises

SQL Exercises, Practice, Solution - UNION

Secondary Nav

SQL [9 exercises with solution]

1. Write a query to display all salesmen and customer located in London. Go to the editor

Sample table : Salesman

Sample table : Customer

Click me to see the solution

2. Write a query to display distinct salesman and their cities. Go to the editor

Sample table : Salesman

Sample table : Customer

Click me to see the solution

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

Click me to see the solution

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 : Customer

Sample table : Orders

Click me to see the solution

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 : Customer

Click me to see the solution

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

Click me to see the solution

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

Click me to see the solution

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

Click me to see the solution

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

Click me to see the solution

 

Go to top



Join our Question Answer community to learn and share your programming knowledge.