×

sql · level 1 · unit 4 · lesson 2

  1. meet it
  2. guess first
  3. your turn
  4. fix it
  5. nailed it

Tap a green word if you get lost.

meet it

The database can do your sums, row by row.

Put a in SELECT and the database works it out for every row. Use + and -, * to multiply and / to divide. Here, each snack's price is worked out for a pack of 3.

The top line of the result shows the calculation itself, like price * 3, because that column has no name of its own yet.

Watch out with /. These prices are integers: whole numbers. Divide one whole number by another and SQL throws the leftover away. Write a , like 100.0, to keep it.

SELECT name, price * 3 FROM snacks;

7 / 2 gives 3, but 7 / 2.0 gives 3.5.