sql · level 1 · unit 3 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
shows each value only once.
Ask the scores table which games were played, and you get darts, darts, bowling, bowling, bowling, darts, darts. Each repeat is a , and they make the answer hard to read.
DISTINCT goes straight after SELECT. It throws away duplicate rows, so each one shows up only once. Here, that leaves darts and bowling.
With two columns, a row only counts as a duplicate when both of its values match another row.
SELECT DISTINCT game FROM scores; DISTINCT works with ORDER BY too, so you can sort the list as well.
guess first
Who played? Guess the result.
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT DISTINCT player FROM scores ORDER BY player;
your turn
Your turn. Which column has repeats?
Type kind in the blank and run it. Then try name instead. Which column had duplicates to throw away?
result
Your answer appears here as a table.
fix it
DISTINCT is in the wrong spot. Can you fix it?
result
Your answer appears here as a table.
- Read the error. Which word does it point near?
DISTINCThas to come straight afterSELECT, before the column names.- Move DISTINCT so the query starts SELECT DISTINCT species, then press run.
nailed it
you cleared out the repeats. :D
DISTINCTshows each row only once.- It goes straight after
SELECT. - Add
ORDER BYto sort the list too.
new words in your collection
- DISTINCT
- duplicate
This lesson isn’t saved. A free account remembers every lesson you finish.