sql · level 1 · unit 3 · lesson 1
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
sorts your result, like lining up by height.
Rows come back in the order they were stored. To sort them, add ORDER BY and a column name at the end of your query, after any WHERE.
The normal order is : smallest first, or A to Z for text. Add DESC for , biggest first. ASC means ascending, if you want to say it out loud.
Sorting only changes the order of the result. The table itself stays exactly as it was.
SELECT player, points FROM scores ORDER BY points DESC; ORDER BY goes after WHERE, because you sieve the rows first and then sort them.
guess first
Names in order. Which pet comes first?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT name FROM pets ORDER BY name;
your turn
Your turn. Sort the films your way.
Pick a column to sort by: title, year or minutes. Then type ASC or DESC in the second blank and press run.
result
Your answer appears here as a table.
fix it
The winner should be at the top. Can you fix it?
result
Your answer appears here as a table.
- The scores are in order, but which end comes first?
- Sorting goes from smallest to biggest unless you say otherwise.
- Add DESC after ORDER BY points, then press run.
nailed it
you put your results in order. :D
ORDER BYsorts the result by a column.- Ascending is the normal order. Add
DESCfor biggest first. ORDER BYcomes afterWHERE.
new words in your collection
- ORDER BY
- ascending
- descending
This lesson isn’t saved. A free account remembers every lesson you finish.