sql · level 1 · unit 5 · lesson 3
- meet it
- guess first
- your turn
- fix it
- 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.
guess first
The longest film. What comes back?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT MAX(minutes) AS longest FROM films;
your turn
Your turn. Find the range of the films.
Type year or minutes in both blanks, the same word twice. The query finds the lowest and highest value in that column.
result
Your answer appears here as a table.
fix it
The top score is missing a bracket. Fix it!
result
Your answer appears here as a table.
- Read the error. Which word does it point near?
- Every bracket you open needs closing. Look straight after points.
- Add ) after points, so it reads MAX(points), then press run.
nailed it
you found the smallest and the biggest. :D
MINfinds the smallest value,MAXthe biggest.- On text, smallest means first from A to Z.
- Ask for several answers at once, each with its own
AS.
new words in your collection
- MIN
- MAX
This lesson isn’t saved. A free account remembers every lesson you finish.