SQL Aliases (AS)
An alias gives a column or table a temporary name for one query. Column aliases make results readable. Table aliases keep joins short.
Updated December 1, 2026
Syntax
SELECT column AS alias_name
FROM table_name AS t;
Rename output columns
The alias only changes the result’s heading, not the table.
SELECT name AS drink, price AS usd
FROM drinks;
| drink | usd |
|---|---|
| Espresso | 3 |
| Latte | 4.5 |
| Cappuccino | 4.25 |
| Mocha | 5 |
Name a calculated column
Without an alias, a calculated column gets a heading like ROUND(price * 0.9, 2). An alias gives it a clear name.
SELECT name, ROUND(price * 0.9, 2) AS member_price
FROM drinks
WHERE category = 'tea';
| name | member_price |
|---|---|
| Matcha Latte | 4.73 |
| Chai Latte | 4.28 |
| Peppermint Tea | 2.93 |
Table aliases in joins
Short table aliases like o and c save typing when you need to say which table a column comes from.
SELECT o.id, c.name, o.ordered_on
FROM orders AS o
JOIN customers AS c ON c.id = o.customer_id
ORDER BY o.id;
| id | name | ordered_on |
|---|---|---|
| 1 | Ava | 2024-07-01 |
| 2 | Ava | 2024-07-01 |
| 3 | Ben | 2024-07-02 |
| 4 | Cara | 2024-07-02 |
| 5 | Dev | 2024-07-03 |
Common mistakes
- Using a column alias in
WHERE. PostgreSQL and SQL Server don’t allow it becauseWHEREruns beforeSELECT; repeat the expression or use a subquery. - Aliases with spaces need double quotes:
AS "member price". Single quotes make text, not a name. - After aliasing a table, using its full name: once you write
orders AS o, refer too.id.
Practice Aliases (AS) interactively
Write real queries in your browser and get instant feedback in the lesson “Rename and dedupe” (Unit 1). New learners can start free from the first lesson.
Frequently asked questions
Is the AS keyword required?
For columns and tables, AS is optional in most databases: SELECT name drink works. Writing AS is clearer. Oracle doesn’t accept AS before table aliases.
Can I use an alias in ORDER BY?
Yes. ORDER BY runs after SELECT, so ORDER BY member_price works everywhere.