Column Aliases and Expression Naming in SQL
By Owen Middleton · Updated September 2026 · Examples run on PostgreSQL 17
Before this SELECT and Column Expressions
Builds toward Self-Joins
What are Column Aliases in SQL?
AS is what you use to name the columns in your result.
Without it, SQL names computed columns for you, and the names it chooses often look broken. Run two numbers through arithmetic and the column might come out labeled ?column? or something equally cryptic. When you share that with a manager, it looks unfinished. AS is how you put the right label on the column before it reaches anyone else.
How do you name a column with AS in SQL?
You write the expression, write AS, then give the column whatever name makes sense. That name appears as the header in your result:
SELECT 2400 AS annual_salary, 2400 / 12 AS monthly_salaryOne row, two clearly labeled columns. The names appear exactly as you wrote them — or close to exactly, which brings up the most common alias mistake.
Why does my column alias come back lowercase?
SQL converts unquoted alias names to lowercase. AS MonthlyRevenue produces a column called monthlyrevenue. To preserve capitals, spaces, or any formatting that makes the label readable, wrap the name in double quotes:
SELECT 8500 - 1200 AS "Net Revenue"Double quotes tell SQL to take the name literally: capitals, spaces, everything. They are also one way to use a SQL reserved word as a column name:
SELECT 100 AS "from", 200 AS "to"
The quotes are not what rescues that, though. AS is. Write the keyword and PostgreSQL takes a reserved word as an alias without any quoting at all: SELECT 100 AS from is valid, and so are AS select and AS order. What breaks is leaving AS out in front of one, because SELECT 100 from starts a FROM clause and the statement runs out before it finds a table. Quote a name when you want capitals or spaces in it; write AS when the name is a keyword.
Is the AS keyword optional in SQL?
For an ordinary name the AS keyword itself is optional. SELECT 9 * 8 hours_worked is valid — hours_worked is the alias even without AS. Omitting it saves a word, but including it makes the intent clear at a glance. Using AS consistently is the safer habit.
You write SELECT 3000 AS MonthlyRevenue. What is the column name in the result?
Practice Column Aliases in SQL
A project manager is building a budget summary for a kickoff meeting. The project combines a design allocation of $350 and a development allocation of $150.
Write a query to return the combined total in a single column named total_budget.
Output:
- A single row with one column named
total_budget, containing the sum of the two allocations.
Run previews · Check grades
Write a query, then run it to see results here.
The full breakdown walks through the shape, each clause, why this approach beats the alternatives, and the trap to avoid.
See the full worked solution9 Column Aliases practice problems
Write a query to return the combined total in a single column named total_budget.
Write a query to return the annual salary and the monthly equivalent in a single row, with the columns named annual_salary and monthly_salary.
Write a query to return the total hours in a single column named hours_worked. The AS keyword is optional — 9 * 8 hours_worked works the same as 9 * 8 AS hours_worked.
Write a query to return all three figures in one row.
Write a query that returns net revenue in a column with that exact name.
Write a query that returns those two values in a single row with the required column names.
Write a query to return all three in a single row.
Write a query that returns net profit in a column with that exact name.
Write a query to return both prices in a single row.
Start learning to practice all 9 Column Aliases problems, with instant grading and mastery tracking.
Common questions about Column Aliases
Can you reuse an alias in another expression in the same SELECT?
No. Every expression in a SELECT list is worked out from the underlying columns, so an alias defined beside it does not exist yet and the query stops with column does not exist. Repeat the expression, or compute it once in a subquery and refer to it outside.
Do you need quotes around an alias with a space in it?
Yes. An unquoted alias has to be a single word, so a two-word name is a syntax error. Wrap it in double quotes and the spaces and capitals survive exactly as you typed them, which is what you want for a heading someone else will read.
Where can a column alias be used in the same query?
In ORDER BY, and in GROUP BY. It is not available to WHERE or HAVING, because both of those are resolved before the SELECT list is. The rule to remember is that an alias exists for the clauses that run after the output columns are worked out.
Should you write AS, or leave it out?
Either works for an ordinary name, and leaving it out saves a word. Writing AS makes the intent obvious at a glance and avoids the case where a missing comma turns the next column name into an accidental alias, which is why it is the safer habit.