Open In App

SQL - SELECT AS

Last Updated : 23 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In SQL, the SELECT AS clause is an essential feature that helps improve query readability and makes our database results more understandable. By aliasing columns and tables, we can provide meaningful names to our output, making complex queries easier to interpret and manage.

In this article, we will explain SQL SELECT AS syntax, its uses, and practical examples to help us become proficient in SQL query optimization.

What is the SQL SELECT AS Clause?

The SELECT AS clause in SQL is used to rename columns or expressions in the result set of a query. This is known as aliasing. Aliases provide a temporary name for a column or expression that makes the results more readable, particularly when working with aggregate functions, joins, or complex calculations.

For instance, instead of displaying a generic column name, we can give it a more meaningful label. This is especially helpful in enhancing the SQL query readability, making it easier for users to interpret results without modifying the underlying table structure.

SQL SELECT AS Syntax

1. Alias for Columns

SELECT column_name AS alias_name
FROM table_name;

Key Terms

  • column_name: The original name of the column in the table.
  • alias_name: The temporary name you want to assign to the column in the output.

2. Alias for Tables

SELECT column_name
FROM table_name AS alias_name;

Key Terms

  • table_name: The original name of the table.
  • alias_name: The temporary name assigned to the table.

Examples Using SELECT AS Clause in SQL

For better understanding of SQL SELECT AS Alias we will consider two tables which are Orders and Customers with multiple columns as defined below:

Table 1: Orders

OrderIDCustomerIDOrderDateTotalAmount
11012024-08-01250
21022024-08-02300
31032024-08-03150
41012024-08-04450
51042024-08-05200

Table 2: Customers

CustomerIDCustomerName
101Alice
102Bob
103Charlie
104Dana

Example 1: Alias for Columns

To select data from the Orders table and rename the columns for clarity, we can use aliases.

Query:

SELECT OrderID AS "Order Number", 
CustomerID AS "Client ID",
OrderDate AS "Date",
TotalAmount AS "Amount"
FROM Orders;

Output

Order NumberClient IDDateAmount
11012024-08-01250
21022024-08-02300
31032024-08-03150
41012024-08-04450
51042024-08-05200

Example 2: Using Aliases With a Space Character

If we want to include spaces in our column aliases, we must enclose the alias name in quotes.

Query:

SELECT CustomerID AS "Customer ID", 
TotalAmount AS "Order Amount"
FROM Orders;

Output

Customer IDOrder Amount
101250
102300
103150
101450
104200

Example 3: Concatenate Columns

To create a full name by concatenating FirstName and LastName columns from the Customers table (assuming it has FirstName and LastName columns), we can use concatenation with an alias.

Query:

SELECT CONCAT(FirstName, ' ', LastName) AS "Full Name"
FROM Customers;

Output

Full Name
Alice Smith
Bob Brown
Charlie Davis
Dana White

Example 4: Alias for Tables

Using aliases for tables can simplify our queries, especially when joining tables. Here’s how we can use table aliases to join the Orders and Customers tables and select specific fields. Where, O is an alias for the Orders table and C is an alias for the Customers table.

Query:

SELECT O.OrderID AS "Order Number", 
C.CustomerName AS "Customer"
FROM Orders O
JOIN Customers C ON O.CustomerID = C.CustomerID;

Output

Order NumberCustomer
1Alice
2Bob
3Charlie
4Alice
5Dana

Conclusion

The SELECT AS clause is an essential tool for creating clean, efficient, and readable SQL queries. Whether we're renaming columns, creating user-friendly reports, or simplifying complex joins, aliases significantly improve the structure of our SQL queries. Mastering the SELECT AS clause will help us write better SQL code, enhance the clarity of our reports, and streamline our database management system.


Article Tags :

Similar Reads