Working out new values
A column in your result doesn't have to exist in the table. You can calculate it with +, -, *
(multiply) and / (divide):
SELECT name, list_price - unit_cost AS margin
FROM productsThis works out each product's margin from two columns in the same row. Give a calculated column an
alias, or it gets an unhelpful name like (list_price - unit_cost).
Prices at Brightwell are stored without VAT. To add 20% VAT, multiply by 1.2:
SELECT name, list_price * 1.2 AS price_inc_vat
FROM productsRounding
Calculations can produce long decimals, like 41.148. ROUND(value, 2) rounds to two decimal
places, which is what you want for money:
SELECT name, ROUND(list_price * 1.2, 2) AS price_inc_vat
FROM products