fg

fg

Posts

Column Alias


Description:

When displaying the result of a query, SQL Developer normally uses the name of the selected column as the column heading. This heading may not be descriptive and, therefore, may be difficult to understand. You can change a column heading by using a column alias.
 By default, alias headings appear in uppercase. If the alias contains spaces or special characters (such as # or $), or if it is case-sensitive, enclose the alias in double quotation marks ("").

Examples:


SELECT last_name AS name, commission_pct comm
FROM   employees;



The select statement displays the names and the commission percentages of all the employees. Note that the optional AS keyword has been used before the column alias name. The result of the query is the same whether the AS keyword is used or not. 
The SQL statement has the column aliases(name and comm) in lowercase, whereas the result of the query displays the column headings in uppercase.
Column headings appear in uppercase by default.

SELECT last_name "Name" , salary*12 "Annual Salary"
FROM   employees;


The select statement displays the last names and annual salaries of all the employees. Because "Annual Salary" contains a space, it has been enclosed in double quotation marks. Note that the column heading in the output is exactly the same as the column alias.

No comments :

Post a Comment