Query results consist of a set of columns. By default, the heading for each column is the expression supplied in the select list.
When query results are displayed, each column's default heading is the name given to it when it was created. You can specify a different column heading, or alias, as follows:
SELECT column-name [ AS ] alias
Providing an alias can produce more readable results. For example, you can change DepartmentName to Department in a listing of departments as follows:
SELECT DepartmentName AS Department, DepartmentID AS "Identifying Number" FROM Departments; |
Department | Identifying Number |
---|---|
R & D | 100 |
Sales | 200 |
Finance | 300 |
Marketing | 400 |
... | ... |
The Identifying Number alias for DepartmentID is enclosed in double quotes because it is an identifier. You also use double quotes if you want to use keywords in aliases. For example, the following query is invalid without the quotation marks:
SELECT DepartmentName AS Department, DepartmentID AS "integer" FROM Departments; |
If you want to ensure compatibility with Adaptive Server Enterprise, you should use quoted aliases of 30 bytes or less.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |