In the SQL Alias command section, we observed that the syntax for using table and column aliases is as shown below:
SELECT “TableAlias”.”ColumnName” “ColumnAlias”
FROM “TableName” “TableAlias”;
The keyword “AS” is mainly used to allot an alias to the column or a table. It is inserted in between the column name and the column alias or in between the table name and the table alias.
The given syntax for using AS is as follows:
SELECT “TableAlias”.”ColumnName1″ AS “ColumnAlias”
FROM “TableName” AS “TableAlias”;
Let’s use the same example as we used in the SQL Alias tutorial. Assume we are equipped with the following table, Store Information.
Table Name : StoreInformatio
StoreName
Sales
TxnDate
Los Angeles
1500
Jan-05-1999
San Diego
250
Jan-07-1999
Los Angeles
300
Jan-08-1999
To calculate the total sales by store using AS as part of the table and column alias, we are going to shoot the following query:
SELECT A1.StoreName Store, SUM(A1.Sales) AS “Total Sales”
FROM StoreInformation AS A1
GROUP BY A1.StoreName;
Outcome:
Store
Total Sales
Los Angeles
1800
San Diego
250
Boston
700
Is there no difference between using an alias without AS and with AS in SQL. There exists no functional difference, as both versions is going to accomplish exactly the same thing.
Any question about sql contact to our helpline number Call @ 1800-865-4183