General Note: Here we have pulled in the data from a sample database. You can download it from the following link and use it for practicing Click Here For Sample Database

In this tutorial, you will learn, how to use alias in SQLite.

Generally, If you do any operation on column the resultant column header will be given the name as the operation performed.

See the query


Select mobile_name,price,price-200  from mobile_sales_details

mobile_name             price       price-200 
----------------------  ----------  ----------
Moto X (16 GB) (Black)  23999       23799     
Moto G (Black  with 16  13999       13799     
Moto E (Black)          6999        6799      
Asus Zenfone 4 A400CG   5999        5799      
Asus Zenfone 5 A501CG   9999        9799      
Asus Zenfone 5 A501CG   12999       12799     
Asus Zenfone 6 A600CG   16999       16799     
Alcatel Onetouch Idol   16999       16799     
Samsung Galaxy S Duos   8206        8006      
Samsung Galaxy Star Pr  7599        7399

In the above query price is subtracted with 200, so the resulting column name will be shown as "price-200". If you want to give your own name to the column header, alias is used. Column alias can be given in two formats, they are

  1. Alias name after the column name with space alone
  2. Alias name after the column name using the AS reserved keyword

Select mobile_name,price,price-200 as special_offer from mobile_sales_details

mobile_name             price       special_offer
----------------------  ----------  -------------
Moto X (16 GB) (Black)  23999       23799        
Moto G (Black  with 16  13999       13799        
Moto E (Black)          6999        6799         
Asus Zenfone 4 A400CG   5999        5799         
Asus Zenfone 5 A501CG   9999        9799         
Asus Zenfone 5 A501CG   12999       12799        
Asus Zenfone 6 A600CG   16999       16799        
Alcatel Onetouch Idol   16999       16799        
Samsung Galaxy S Duos   8206        8006         
Samsung Galaxy Star Pr  7599        7399         
Samsung Galaxy S Duos   8214        8014         
Samsung Galaxy Core I8  11795       11595        
Samsung Galaxy Grand 2  18990       18790

In the above query we have used AS keyword to display the special_offer for price-200.

The same query can be written without AS keyword


Select mobile_name,price,price-200 special_offer from mobile_sales_details

mobile_name             price       special_offer
----------------------  ----------  -------------
Moto X (16 GB) (Black)  23999       23799        
Moto G (Black  with 16  13999       13799        
Moto E (Black)          6999        6799         
Asus Zenfone 4 A400CG   5999        5799         
Asus Zenfone 5 A501CG   9999        9799         
Asus Zenfone 5 A501CG   12999       12799        
Asus Zenfone 6 A600CG   16999       16799        
Alcatel Onetouch Idol   16999       16799        
Samsung Galaxy S Duos   8206        8006         
Samsung Galaxy Star Pr  7599        7399         
Samsung Galaxy S Duos   8214        8014         
Samsung Galaxy Core I8  11795       11595        
Samsung Galaxy Grand 2  18990       18790

You will get the same result, here the AS keyword is not mandatory but its used for clarity. You can easily figure out which one alias, if you write a large query.

Space in column header will not be allowed, therefore we have used _ (underscore) in the above query. If you want give column header with space, you have to write your alias name inside double quote(“ ”).


Select mobile_name,price,price-200 as “Special offer” from mobile_sales_details

mobile_name             price       Special offer
----------------------  ----------  -------------
Moto X (16 GB) (Black)  23999       23799        
Moto G (Black  with 16  13999       13799        
Moto E (Black)          6999        6799         
Asus Zenfone 4 A400CG   5999        5799         
Asus Zenfone 5 A501CG   9999        9799         
Asus Zenfone 5 A501CG   12999       12799        
Asus Zenfone 6 A600CG   16999       16799        
Alcatel Onetouch Idol   16999       16799        
Samsung Galaxy S Duos   8206        8006         
Samsung Galaxy Star Pr  7599        7399         
Samsung Galaxy S Duos   8214        8014         
Samsung Galaxy Core I8  11795       11595        
Samsung Galaxy Grand 2  18990       18790        
Samsung Galaxy Trend S  9610        9410

Select mobile_name Mobile ,price “Selling Price” ,price-200 as “Special offer” from mobile_sales_details

Mobile                  Selling Price  Special offer
----------------------  -------------  -------------
Moto X (16 GB) (Black)  23999          23799        
Moto G (Black  with 16  13999          13799        
Moto E (Black)          6999           6799         
Asus Zenfone 4 A400CG   5999           5799         
Asus Zenfone 5 A501CG   9999           9799         
Asus Zenfone 5 A501CG   12999          12799        
Asus Zenfone 6 A600CG   16999          16799        
Alcatel Onetouch Idol   16999          16799        
Samsung Galaxy S Duos   8206           8006         
Samsung Galaxy Star Pr  7599           7399         
Samsung Galaxy S Duos   8214           8014         
Samsung Galaxy Core I8  11795          11595        
Samsung Galaxy Grand 2  18990          18790        
Samsung Galaxy Trend S  9610           9410         
Samsung Galaxy Grand N  14010          13810        
Samsung I8552 - Galaxy  15999          15799        
Samsung Galaxy S4 Mini  24730          24530        
Samsung GT 1200 R/I/M   1299           1099         
Samsung Guru 1200 (Bla  1399           1199         
Samsung Galaxy S5 (Cha  54300          54100