Complete the code to select the total price by multiplying quantity and price_per_unit.
SELECT quantity * [1] AS total_price FROM orders;The column price_per_unit holds the unit price. Multiplying it by quantity gives the total price.
Complete the code to calculate the discount amount by multiplying price and discount_rate.
SELECT price * [1] AS discount_amount FROM products;The discount_rate column holds the rate to calculate the discount. Multiplying it by price gives the discount amount.
Fix the error in the code to compute the total cost including tax.
SELECT price * quantity + price * quantity * [1] AS total_cost FROM sales;The tax_rate column holds the tax percentage. Multiplying it by the total price (price * quantity) adds the tax amount.
Fill both blanks to calculate the final price after discount.
SELECT price * [1] AS discount_amount, price - [2] AS final_price FROM items;
The first blank uses discount_rate to calculate the discount amount. The second blank uses discount_amount to subtract from price for the final price.
Fill all three blanks to compute total cost including tax and discount.
SELECT price * quantity AS subtotal, subtotal * [1] AS tax_amount, subtotal - subtotal * [2] + [3] AS total_cost FROM orders;
The first blank is tax_rate to calculate tax amount from subtotal. The second blank is discount_rate to calculate discount from subtotal. The third blank is tax_amount to add tax back after discount.