By: Kris Wenzel   |   Updated: March 6, 2022  
Works With: 

Rename Columns with SQL SELECT AS

You can use a form of SQL SELECT AS to rename columns in your query results.

So far you’ve seen where queries results return results named after the table columns. This is fine for most cases, but once you start working with expressions, you’ll see this doesn’t work well.

To rename a column use AS.

In this example we’re renaming FirstName to First and LastName to Last.

The AS is optional, can you rewrite the above SQL without using AS?

Renaming columns may seem like a nice to have feature, but it also comes in handy when we want to return a calculated result.

For instance, suppose you wanted to return the LastName in all upper case. You could write

FROM Person.Person
SQL SELECT AS - No Column name specified.

But once you run the query, you’ll see no column name is returned. To ensure the column is given a name, you can use AS.

your Turn!

Can you write a query to return a distinct list of upper case first names? Name the column [Distinct Names].

Write your query below they try it.

Additional SELECT Statement Resources

If you’re looking to learn more about the SELECT command, the I would recommend you read our article Simple Select Queries.

To learn more about functions, such as UPPER, check out our article Introduction to Common String Functions.

Looking for a super SQL book? Check out SQL Queries for Mere Mortals.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}