SQL · Level 1 Basics

SQL SELECT and Calculated Columns

Show each product's price with VAT: pick columns with SELECT, compute a new one, name it with AS and round money with ROUND.

  • SELECT columns FROM table
  • Calculations in SELECT
  • AS names a column
  • ROUND(x, 2) for money

SELECT lists the columns you want, and a column can be a calculation; AS gives it a name. Trap: money maths in floating point gives values like 23.987999999999996. Wrap it in ROUND(x, 2).

SELECT name,
       price * 1.2           AS raw,      -- 23.987999999999996
       ROUND(price * 1.2, 2) AS with_vat  -- 23.99
FROM products;

Return each product's name and its price with 20% VAT (price * 1.2) rounded to 2 decimals. In the database below, the Notebook costs 23.99 with VAT.

Sample data from the first test. The other tests use different rows, so write a query, not a list of answers.

products 3 rows
idINTEGERnameTEXTpriceREAL
1Notebook19.99
2Pen2.5
3Lamp35.0
solution.sql
Test Suites Pending
Output