0
0
MySQLquery~10 mins

Why computed values add flexibility in MySQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select the total price by multiplying quantity and price_per_unit.

MySQL
SELECT quantity * [1] AS total_price FROM orders;
Drag options to blanks, or click blank then click option'
Aprice_per_unit
Btotal
Cprice
Dcost
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column name that does not exist in the table.
Forgetting to multiply quantity by the unit price.
2fill in blank
medium

Complete the code to calculate the discount amount by multiplying price and discount_rate.

MySQL
SELECT price * [1] AS discount_amount FROM products;
Drag options to blanks, or click blank then click option'
Arate
Bdiscount
Cdiscount_rate
Ddiscount_percent
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not represent the discount rate.
Confusing discount amount with discount rate.
3fill in blank
hard

Fix the error in the code to compute the total cost including tax.

MySQL
SELECT price * quantity + price * quantity * [1] AS total_cost FROM sales;
Drag options to blanks, or click blank then click option'
Atax_rate
Btax
Ctaxamount
Drate
Attempts:
3 left
💡 Hint
Common Mistakes
Using a column that does not represent the tax rate.
Forgetting to multiply tax rate by the total price.
4fill in blank
hard

Fill both blanks to calculate the final price after discount.

MySQL
SELECT price * [1] AS discount_amount, price - [2] AS final_price FROM items;
Drag options to blanks, or click blank then click option'
Adiscount_rate
Bdiscount_amount
Cdiscount
Drate
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up discount rate and discount amount.
Using the same column for both blanks.
5fill in blank
hard

Fill all three blanks to compute total cost including tax and discount.

MySQL
SELECT price * quantity AS subtotal, subtotal * [1] AS tax_amount, subtotal - subtotal * [2] + [3] AS total_cost FROM orders;
Drag options to blanks, or click blank then click option'
Atax_rate
Bdiscount_rate
Ctax_amount
Ddiscount_amount
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing tax and discount columns.
Using discount amount before calculating it.