Home » SQL Basics » Retrieving Data » Using ALIAS



Syntax: SELECT “table_alias”.”column_name1″ as “column_alias1” , “table_alias”.”column_name2″ as “Column_Alias2,….”table_alias”.”column_nameZ” as “Column Alias3” FROM “table_name” “table_alias”

Example: SELECT A.store_name as Store, SUM(A.Sales) as “Total Sales”
FROM Store_Sales A
GROUP BY A.store_name

In the above example it displays all Individual Stores with thier Sum of Sales.
Note: Group by list should contain all columns in the Select List except ones which are used in Arthemitic functions like Sum.

Leave a Reply

Your email address will not be published. Required fields are marked *