SQL Alias is used to organize the output, to make it easy to read and more meaningful. SQL Alias can be used with database tables or database table columns.
SQL Alias Syntax
SELECT T.Column1 AS c1, T.Column2 AS c2, T.Column3 AS c3, ... FROM TABLE1 AS T
SQL Alias Example
Table: Employees
EmployeeId | FirstName | LastName | Department | Salary |
---|---|---|---|---|
203 | Marfg | Fxun | Finance | 78000 |
204 | Joznk | Llnyo | Finance | 45800 |
205 | Hasuu | Kynuoo | Finance | 57000 |
206 | Jkucc | Qihha | Finance | 62000 |
302 | Biee | Uioooi | Development | 75000 |
303 | Kmoao | Astuu | Development | 55000 |
304 | Pissue | Koooi | Development | 49000 |
Select the total number of employees:
SELECT COUNT(E.EmployeeId) AS totalEmployees FROM Employees AS E
The result will look like:
totalEmployees |
---|
7 |