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_table
Example 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 Use If Else in SQL Select Statement
In SQL, conditional logic plays a crucial role in dynamically modifying query outputs based on specific conditions. The IF...ELSE construct is widely used to implement such logic. By using IF...ELSE within SQL statements we can categorize data, apply conditional transformations, and implement busine
4 min read
How to Use a Subquery in a SELECT Statement
A subquery also known as a nested query is a query embedded within another query to perform advanced filtering or computation. In the context of a SELECT statement, subqueries allow retrieving values or conditions dynamically by enabling complex and flexible data extraction. In this article, We will
4 min read
How to Update a Column in a Table in SQL Server
In the database management area, updating columns in a table is a normal query and it is important software that ensures the accuracy and integrity of data. Whether we are making spelling corrections, editing or altering existing information, or being attentive to changing requirements, carrying out
4 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 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 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 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
How to Change a Column Name in SQL?
The ALTER TABLE statement in SQL is a powerful command used to modify the structure of an existing table without affecting its data. It enables changes like adding, dropping, renaming or altering columns in the table. Among these operations, altering a column with the CHANGE or RENAME command is com
3 min read