Page 165 - SQL
P. 165
FirstName LastName
James Smith
John Johnson
Michael Williams
A further variation available in MS SQL Server amongst others is <alias> = <column-or-
calculation>, for instance:
SELECT FullName = FirstName + ' ' + LastName,
Addr1 = FullStreetAddress,
Addr2 = TownName
FROM CustomerDetails
which is equivalent to:
SELECT FirstName + ' ' + LastName As FullName
FullStreetAddress As Addr1,
TownName As Addr2
FROM CustomerDetails
Both will result in:
FullName Addr1 Addr2
James Smith 123 AnyStreet TownVille
John Johnson 668 MyRoad Anytown
Michael Williams 999 High End Dr Williamsburgh
Some find using = instead of As easier to read, though many recommend against this format,
mainly because it is not standard so not widely supported by all databases. It may cause
confusion with other uses of the = character.
All Versions of SQL
Also, if you need to use reserved words, you can use brackets or quotes to escape:
SELECT
FName as "SELECT",
MName as "FROM",
LName as "WHERE"
FROM Employees
Different Versions of SQL
https://riptutorial.com/ 147

