An Alias is a shorthand for a table or column name.
Aliases reduce the amount of typing required to enter a query.
Complex queries with aliases are generally easier to read.
Aliases are useful with JOINs and aggregates: SUM, COUNT, etc.
An Alias only exists for the duration of the query.
SQL Alias Examples
Problem: List total customers in each country.
Display results with easy to understand column headers.
SELECT COUNT(C.Id) AS TotalCustomers, C.Country AS Nation
FROM Customer C
GROUP BY C.Country
TotalCustomers and Nation are column aliases.
The table alias (C) in this example is not particularly useful.
Problem: List the total amount ordered by customer
with easy to read column headers
SELECT C.Id AS Identifier, C.LastName + ', ' + C.FirstName AS CustomerName,
SUM(O.TotalAmount) AS TotalSpent
FROM [Order] O JOIN Customer C ON O.CustomerId = C.Id
GROUP BY C.Id, C.LastName + ', ' + C.FirstName
ORDER BY TotalSpent DESC
The aliases significantly simplify writing the JOIN and ORDER BY clauses.
The C alias in C.Id helps identify the Customer Id rather then the Order Id.