Communicator e3000 MPE/iX Release 7.5 (Software Release C.75.00) (30216-90336)

Chapter 5
Technical Articles
AS Clause Enhancement in ALLBASE/SQL
118
AS Clause Enhancement in ALLBASE/SQL
by Sekhar N.D CSY Databases
Objectives of the Enhancement
The objective of the enhancement is to allow users to specify an alias name for the items in the Select
Statement. The specified alias name is returned as the column heading in the query result.
Usage of Column Alias Name
The syntax of the Select Statement with Alias Name:
==========
SYNTAX
==========
-- Select Statement Level --
[BULK] QueryExpression [ORDER BY {ColumnID [ASC ]} [,...]]
[ { [DESC]} ]
-- Subquery Level --
(QueryExpression)
-- Query Expression Level --
{QueryBlock } [UNION [ALL] {QueryBlock }] [...]
{(QueryExpression)} [ {(QueryExpression)}]
-- Query Block Level --
SELECT [ALL ] SelectList [INTO HostVariableSpecification]
[DISTINCT]
FROM FromSpec [,...] [WHERE SearchCondition1] [GROUP BY GroupColumnList]
[HAVING SearchCondition2]
where SelectList =
{* }
{[Owner.]Table.* }
{CorrelationName.* } [,...]
{Expression [AS] Alias_name }
{[[Owner.]Table.]ColumnName [AS] Alias_name }
{CorrelationName.ColumnName [AS] Alias_name}
where Alias_name can be an identifier, a single-quoted string or a
double-quoted string
=========
EXAMPLE
=========
SELECT PartNumber [AS] "Part Number" , AVG (UnitPrice) [AS] avg_price,
AVG (deliverydays) [AS] avg days FROM PurchDB.SupplyPrice GROUP BY
partnumber;
If the alias name is specified as an identifier it should conform to the following rules which are the rules
defined for Basic Names in ALLBASE/SQL: