×

sql · level 1 · unit 5 · lesson 4

  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

tidies long decimals into neat answers.

The average bowling score is 108.33333333333333. Nobody needs all those 3s. ROUND(AVG(points), 1) rounds it to one decimal place: 108.3.

Inside ROUND, the first value is the number and the second is how many to keep. Each bracket you open needs closing.

Put several aggregates in one query, each with an alias, for a mini report. Careful: COUNT(*) counts rows, but COUNT(borrower) counts only the boxes that are not NULL.

SELECT COUNT(*) AS games,
  MAX(points) AS best,
  ROUND(AVG(points), 1) AS average
FROM scores WHERE game = 'bowling';

A long query can spread over several lines, because only the semicolon marks its end.