MySQL Practice Exercises with Solutions – Ordering System Database – Part 9
We have split this collection of exercises on MYSQL into seven parts, this is the first one, then you will find the second part, the third part, the fourth part, the fifth part, the sixth part, seventh part, eighth part, and finally the ninth part these exercises are based on simple, advanced and finally complex MYSQL queries. These questions are based on the following three tables, Customer, Orders and OrderLine table.
Customer table
Orders table
OrderLine table
Questions
1. Get the user with the first name “Ivan” and the password “password2”, considering that the encoding of the password is done with the Sha1 algorithm.
2. Get the list of all products that are present on several orders.
3. Get the list of all the products that are present on several orders and add a column that lists the id of the associated orders.
4. Store the total price within each order line, based on the unit price and quantity.
5. Get the total price for each order and the date associated with that order as well as the first and last name of the associated customer.
6. Store the total price of each order in the field named “order_total_price”.
7. Get the total price of all orders, for each month.
8. Get a list of the 10 customers who made the largest amount of orders, and get this total price for each customer.
9. Get the total price of orders for each date.
10. Add a column named “category” to the table containing the orders. This column will contain a numerical value.
11. Enter the value of the category, according to the following rules:
- “1” for orders under 200€.
- “2” for orders between 200€ and 500€.
- “3” for orders between 500€ and 1.000€.
- “4” for orders over 1.000€.
12. Create a table called “category_order” which will contain the description of these categories.
13. Insert the 4 descriptions of each category in the table previously created.
- “1” for orders under 200€.
- “2” for orders between 200€ and 500€.
- “3” for orders between 500€ and 1.000€.
- “4” for orders over 1.000€.
14. Delete all orders (and orderLines) below January 7, 2022.