How to Use Column Alias in SELECT Statement?
Last Updated :
06 Jan, 2025
When working with SQL queries, readability and clarity are crucial for efficient data analysis. Using column aliases in the SELECT
statement can significantly improve the clarity of our output by providing more meaningful and user-friendly names to the columns. Aliases are especially useful when working with complex queries, calculated fields, or when the original column names are not descriptive enough.
In this article, we will explain how to use column aliases in SQL, the syntax for implementing them, best practices, and practical examples to help us understand their importance and application. By the end of this article, we'll be able to use column aliases effectively to make our SQL queries more readable and presentable.
What is a Column Alias in SQL?
A column alias is a temporary name assigned to a column or expression in the result set of an SQL query. It is used to make column names more descriptive or user-friendly. Column aliases do not change the actual column name in the database; they only appear in the output of the query.
For example, instead of displaying a column name like ENDNAME
, we can use a column alias to display it as LASTNAME
in the result set. The syntax for using column aliases in SQL is straightforward. We can use the AS
keyword to assign an alias to a column or simply specify the alias without the keyword.
Syntax for Table Alias:
SELECT * FROM table_name AS alias_name;
Syntax for Column Alias:
SELECT column_name AS alias_name FROM table_name;
For this guide, we'll use a sample table named demo_table
in a database called geeks
.
demo_tableExample 1: Using a Simple Column Alias
In this example, perform a column alias on the ENDNAME
column. We will use LASTNAME
as the alias name. The column firstname
is renamed as Name
and age
is renamed as Age
. The aliases make the result set more readable by using simple, user-friendly names.
Query:
SELECT FIRSTNAME, ENDNAME AS LASTNAME, AGE, GENDER
FROM demo_table;
Output

Example 2: Using Aliases with Special Characters or Spaces
When using special characters or spaces in an alias name, enclose the alias in double quotes. Here, firstname
is displayed as "First Name" and lastname
as "Last Name" in the output. FIRSTNAME
was displayed as FIRST NAME
, and ENDNAME
was displayed as LAST NAME.
Query:
SELECT FIRSTNAME AS "FIRST NAME", ENDNAME AS "LAST NAME", AGE, GENDER
FROM demo_table;
Output

Conclusion
Using column aliases in SQL is a simple yet powerful way to enhance the readability and presentation of our query results. By applying meaningful aliases to our columns, we can make our SQL output more user-friendly and easier to interpret. Always follow best practices, such as using the AS
keyword and enclosing aliases with spaces in double quotes, to write efficient and clean SQL queries.
Similar Reads
How to Rename a Column in MySQL?
Renaming columns in MySQL is a frequent task to keep data organized and flexible. It helps adjust database layouts to fit new needs without losing information. This article will show you different ways to rename columns in MySQL, making it easier to manage and update your database structure as your
4 min read
How To Select Only One Column Using SQLAlchemy?
In this article, we are going to see how to select only one column using SQLAlchemy in Python. SQLAlchemy is a large SQL toolkit with lots of different components. The two largest components are SQLAlchemy Core and SQLAlchemy ORM. The major difference between them is SQLAlchemy Core is a schema-cent
3 min read
How to Use Reserved Words as Column Names in SQL?
In SQL, certain words are reserved. These are called Keywords or Reserved Words. These words cannot be used as identifiers i.e. as column names in SQL. But, there is an exception to this rule too. In this article, we will discuss how to use Reserved Words as column names in SQL. For this article, we
2 min read
How to Rename a Column in PL/SQL?
Renaming a column in PL/SQL is a fundamental operation in Oracle Database management. It enhances clarity, maintains consistency, or accommodates evolving data requirements. Database administrators can ensure the data integrity and process of streamlining data manipulation by altering the column nam
4 min read
How to Use SELECT With Aggregate Functions in SQL?
SQL aggregate functions are essential tools for summarizing and processing data. These functions help us perform calculations on a set of values to produce a single result, such as SUM, COUNT, AVG, MAX, and MIN. These functions work with the SELECT statement to process data and derive meaningful ins
4 min read
How to Create and Use Alias Command in Linux
Imagine you're lost in a maze of complicated Linux commands. You stumble upon a secret doorway marked "Alias," and inside you find shortcuts to all your favorite commands! That's what creating aliases is like. You get to make your own mini-commands for the long ones you use all the time, making thin
6 min read
How to Update Multiple Columns in Single Update Statement in SQL?
The SQL UPDATE statement is a important operation for modifying existing records in a database table. It allows us to change the values of one or more columns in a table based on specific conditions. In many cases, we may need to update multiple columns in a single operation to keep our data consist
4 min read
How to Add Column in View in PL/SQL?
In Oracle PL/SQL, adding a column to a view is not done through the ALTER VIEW command since it does not directly support adding columns. Instead, views are modified by recreating them using the CREATE OR REPLACE VIEW statement, which allows the addition of new columns while retaining the existing s
3 min read
How to Select Individual Columns in SQL?
In SQL, sometimes we require to select individual columns from a table. For this, we use a specific kind of query shown in the below demonstration. For this article, we will be using the Microsoft SQL Server as our database and Select keyword. Select is the most commonly used statement in SQL. The S
2 min read
How to Get Column Names in MySQL?
To get column names in MySQL use techniques such as the DESCRIBE statement, INFORMATION_SCHEMA.COLUMNS, and SHOW COLUMNS FROM commands. Here will cover these techniques, with explained examples, and help to get a better understanding on how to get column names in MySQL. MySQL Fetch Column Names from
3 min read