Course contentsShow
← Data Science
Lesson 853 of 2,14522. SQL FoundationsFree lesson

Column Aliases with AS

Rename columns in query results using the AS keyword to create more readable or business-friendly output.

Column Aliases with AS

You'll learn how to rename columns in your SQL query results to make them clearer and more professional.

What Are Column Aliases?

When you write SQL queries, the column names that appear in your results are usually the exact names stored in the database table. Sometimes these names are cryptic, abbreviated, or just not user-friendly. A column alias lets you assign a temporary, alternative name to a column in your query output—like giving it a nickname just for that result set.

Why Use AS?

The AS keyword creates these aliases. Think of it like introducing someone: "This is Robert, as Bob." The database still knows the column by its real name, but your results will display the friendlier version you chose.

This is especially valuable when:

  • Database columns have technical names like cust_id or amt_tot
  • You want business-friendly labels like Customer ID or Total Amount
  • You're creating calculated values that need descriptive names

Basic Syntax

SELECT column_name AS new_name
FROM table_name;

Example in Action

SELECT 
    emp_id AS employee_id,
    fname AS first_name,
    sal AS salary
FROM employees;

Instead of seeing columns labeled emp_id, fname, and sal, your results will show employee_id, first_name, and salary—much clearer for reports or sharing with non-technical stakeholders.

Note: The AS keyword is actually optional in most SQL systems (you can write fname first_name), but using it makes your intention crystal clear.

Key Takeaway: Column aliases with AS let you rename columns in query results, transforming technical database names into readable, business-appropriate labels without changing the underlying table structure.