Contents Index Selecting specific columns from a table Character strings in query results

ASA SQL User's Guide
  Queries: Selecting Data from a Table
    The SELECT list: specifying columns

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, in one of the following ways:

SELECT column-name AS alias

SELECT column-name alias

SELECT alias = column-name

Providing an alias can produce more readable results. For example, you can change dept_name to Department in a listing of departments as follows:

SELECT dept_name AS Department,
   dept_id AS "Identifying Number"
FROM department
Department Identifying Number
R & D 100
Sales 200
Finance 300
Marketing 400
... ...
Using spaces and keywords in alias 

The Identifying Number alias for dept_id is enclosed in double quotes because it is an identifier. You also use double quotes if you wish to use keywords in aliases. For example, the following query is invalid without the quotation marks:

SELECT dept_name AS Department,
   dept_id AS "integer"
FROM department

If you wish to ensure compatibility with Adaptive Server Enterprise, you should use quoted aliases of 30 bytes or less.


Contents Index Selecting specific columns from a table Character strings in query results