Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 10.0.1 » SQL Anywhere Server - SQL Usage » Queries: Selecting Data from a Table » The SELECT list: specifying columns

Selecting specific columns from a table Next Page

Renaming columns in query results


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
... ...
Using spaces and keywords in alias

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.