The dataset archive for this task, in CSV format, can be found here.
-
Write an SQL query that will display the
order_details
table and thecustomer_id
field from theorders
table corresponding to each record in theorder_details
table. This should be done using a nested query in theSELECT
statement. -
Write an SQL query that will display the
order_details
table. Filter the results so that the corresponding record from theorders
table meets the conditionshipper_id = 3
. This should be done using a nested query in theWHERE
operator. -
Write an SQL query, nested in the
FROM
operator, that will select rows with the conditionquantity > 10
from theorder_details
table. For the obtained data, find the average value of thequantity
field — grouping should be done byorder_id
. -
Solve task 3 above using the
WITH
operator to create a temporary tabletemp
. If your version of MySQL is earlier than 8.0, create this query similarly to how it is done in the lecture notes. -
Create a function with two parameters that will divide the first parameter by the second. Both parameters and the return value should be of type
FLOAT
. Use theDROP FUNCTION IF EXISTS
construct. Apply the function to thequantity
attribute of theorder_details
table. The second parameter can be any number of your choice.
Solutions are represented in homework folder:
- Part 1: solution for this task part is placed in homework/p1 folder.
- Part 2: solution for this task part is placed in homework/p2 folder.
- Part 3: solution for this task part is placed in homework/p3 folder.
- Part 4: solution for this task part is placed in homework/p4 folder.
- Part 5: solution for this task part is placed in homework/p5 folder.