The dataset archive for this task, in CSV format, can be found here.
-
Write an SQL query that will display the
order_detailstable and thecustomer_idfield from theorderstable corresponding to each record in theorder_detailstable. This should be done using a nested query in theSELECTstatement. -
Write an SQL query that will display the
order_detailstable. Filter the results so that the corresponding record from theorderstable meets the conditionshipper_id = 3. This should be done using a nested query in theWHEREoperator. -
Write an SQL query, nested in the
FROMoperator, that will select rows with the conditionquantity > 10from theorder_detailstable. For the obtained data, find the average value of thequantityfield — grouping should be done byorder_id. -
Solve task 3 above using the
WITHoperator 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 EXISTSconstruct. Apply the function to thequantityattribute of theorder_detailstable. 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.