Aliases in SQL are used to give a temporary name to a table or a column name. The temporary name added to the table or column is valid till the duration of the query. Aliases so as not to change the table name or the column names permanently. An Alias can be created by using AS keyword.
- Syntax to write an Alias –
SELECT column_name1 AS alias_name, column_name2 AS alias_name2,... FROM table_name;
Here in the SELECT statement, the alias mentioned with the column_name will appear in the output. But it will only stay till the duration of the query.
Example – Consider the Product table of the Customer database, and add an alias to the Customer name and the Country/Region.
SELECT [Customer Name] AS NAME , [Country/Region] AS COUNTRY FROM [dbo].[Products];
This output is the small section of the output by executing the above query –
NAME | COUNTRY |
Suzanne McNair | United States |
Amy Hunt | United States |
Amy Hunt | United States |
Emily Phan | United States |
Emily Phan | United States |
Tracy Poddar | United States |
Tracy Poddar | United States |
Anthony Rawles | United States |
Helen Andreada | United States |
Helen Andreada | United States |
Other SQL topics to check out:
- How to write SQL Select Statements
- Introduction to SQL for Data Scientists
- What is RDBMS (Relational Database Management System)?
- SQL WHERE Clause
Follow us on Twitter, Facebook, Linkedin, and Tableau Public to stay updated with our latest blog and what’s new in Tableau.
If you are looking forward to getting your data pipeline built and setting up the dashboard for business intelligence, book a call now from here.
#analytics #data #business #artificialintelligence #machinelearning #startup #deeplearning #deeplearning #datascience #ai #growth #dataanalytics #india #datascientist #powerbi #dataanalysis #tableau #SQL #businessanalytics #businessanalyst #businessandmanagement #dataanalyst #businessanalysis #analyst #analysis #powerbideveloper #powerbidesktop #letsviz