×

sql · level 1 · unit 5 · lesson 3

  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

finds the smallest value and the biggest.

MIN(price) looks down the price column and hands back the smallest value. MAX(price) hands back the biggest. Each gives one answer, like COUNT and SUM.

They work on text too. For text, smallest means first from A to Z, so MIN(name) finds the name that would come first in a dictionary.

You can ask for several answers at once, with commas between. Give each one a name with AS, so you can tell them apart.

SELECT MIN(price) AS cheapest, MAX(price) AS dearest FROM snacks;

MIN and MAX hand back the value itself, not the row it came from.