sql · level 1 · unit 4 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
gives a column a better name.
A top line like price * 3 is hard to read. Write AS and a new name after it, and the result uses that name instead. The new name is called an .
Use one word, or join words with underscores, like pack_price. Leave out spaces, or SQL cannot tell where the name ends.
An alias only changes the result. The column in the table keeps its old name.
SELECT name, price * 3 AS pack_price FROM snacks; AS can be left out, so SELECT name age quietly renames name to age: one more reason commas matter.
guess first
A new name. What does the top line say?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT title, minutes AS running_time FROM films WHERE year = 2023;
your turn
Your turn. Name your own column.
Pick a name for the doubled price, using letters and underscores, like two_pack. Type it after AS, then press run.
result
Your answer appears here as a table.
fix it
A space has crept into the name. Can you fix it?
result
Your answer appears here as a table.
- Read the error. Which word does it point near?
- An alias must be one word. SQL takes dog as the name and does not know what years is for.
- Join the words with an underscore, so it reads dog_years, then press run.
nailed it
you gave your columns proper names. :D
ASgives a column in your result a new name.- Use one word or underscores, never spaces.
- An alias changes the result, not the table.
new words in your collection
- AS
- alias
This lesson isn’t saved. A free account remembers every lesson you finish.