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
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;
We just sent you an email. Please click the link in the email to confirm your subscription!
OKSubscriptions powered by Strikingly