×

sql · level 1 · unit 5 · 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

adds a column up. finds its average.

SUM(points) adds up every value in the points column and hands back the total. Like COUNT, it squashes many rows into one answer.

AVG(points) finds the average: the total, divided by how many values there are. Averages often have decimals, even when every value is a whole number.

You can put a calculation inside the brackets. SUM(price * stock) works out each row first, then adds up the answers.

SELECT SUM(points) AS total, AVG(points) AS average FROM scores WHERE game = 'darts';

SUM and AVG skip any NULL boxes, so empty values do not count.