Problem Bank for Pre Test Problems¶
We use SQL to manage the equipment in a gym. Our current table equipment looks like this:
To help us refill some sport equipments that are low in stock,
please write a SELECT statement to retrieve the name and brand of all items
in the table equipment that belongs to sport category of “table_tennis” and
has a quantity of less than 10.
note: When you run the code, there will be several execution results. Please only refer to the unittest and the last execution result for debugging purposes.
In the same equipment table:
We just bought more equipment for table tennis.
Please write an UPDATE statement that: for all entries which sport column is table_tennis,
add the quantity by 5.
note: When you run the code, there will be several execution results. Please only refer to the unittest and the last execution result for debugging purposes.
Aside from the equipment table:
As students can rent items from the gym, we have another table rental:
Where the equipment_id in this table refers to the id in the equipment table above.
To provide sports-related recommendations for people, we want to know when each individual
played a certain sport.
Please write a statement using SELECT and JOIN to: select the sport from the equipment
table and name and date from the rental table, where the equipment_id in the
rental table is the same as the id in the equipment table.
note: When you run the code, there will be several execution results. Please only refer to the unittest and the last execution result for debugging purposes.