Column Aliases with AS
Sometimes column names aren't clear or you want to rename them in your output. Aliases let you give columns temporary names.
The AS Keyword
SELECT column_name AS alias_name FROM table_name;
The alias only affects the output - it doesn't change the actual column name in the database.
Exercises
Loading exercise...
Loading exercise...
Loading exercise...
Optional AS Keyword
In many SQL databases, the AS keyword is optional:
-- These are equivalent:
SELECT name AS username FROM users;
SELECT name username FROM users;
However, using AS makes your queries more readable.
Common Use Cases for Aliases
Aliases are helpful when:
- Column names are cryptic (e.g.,
usr_nmbecomesuser_name) - You're doing calculations (e.g.,
price * quantity AS total) - Column names would conflict in joins
- You want clearer output for reports
Loading exercise...
Free Practice
Loading SQL editor...
Experiment with:
- Aliases without the AS keyword
- Aliases with special characters (use double quotes)
- Mixing aliased and non-aliased columns

