Learn SQL Lesson
Naming Results with Aliases
Aliases let you give columns or tables a temporary name inside a query.
For columns, aliases make results easier to read:
SELECT name AS employee_name, salary AS annual_salary
FROM employees
The underlying table still has columns named `name` and `salary`. Only the query result uses `employee_name` and `annual_salary`.
Aliases are especially useful when expressions would otherwise have awkward names:
SELECT salary * 0.10 AS annual_bonus
FROM employees
Tables can have aliases too. You will see this often in joins:
SELECT e.name
FROM employees AS e
Here `e` is a short temporary name for `employees`. It keeps longer queries readable.
Practice challenge
Select employee names and salaries, but alias the columns as employee_name and annual_salary.