UPDATESQL

Unit 2, lesson 5 · Calculations, ROUND

Calculated columns and ROUND

Price with tax

You can do arithmetic in SELECT with + - * / and give the result a name with AS. Results often have long decimals: splitting a $50 bill three ways is 50 / 3.0, which is 16.666... ROUND(value, 2) rounds to 2 decimal places, so ROUND(50 / 3.0, 2) is 16.67. The second number is how many decimal places to keep; with no second number, ROUND(50 / 3.0) rounds to a whole number, 17.

Example
SELECT name,
       price,
       ROUND(price * 0.9, 2) AS member_price
FROM products;

Your task

Customers in Texas pay 8.25% sales tax. Show every product's name, price and price_with_tax, rounded to cents.

Tables you will use: products

Try it in your browserFree, no sign-up. Your query is checked as you go.