Using AS with Column Labels
The examples in this section show workarounds that use the AS keyword with a column label. The first two examples show how you can use the keyword UNITS (or YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, or FRACTION) as a column label.
Using units as a column label causes the next example to
fail because the database server interprets it as part of an
INTERVAL expression in which the mycol column is the operand
of the UNITS operator:
SELECT mycol units FROM mytab;
The workaround in the following example includes the AS keyword:
SELECT mycol AS units FROM mytab;
The following example uses the AS or FROM keyword as a column label.
Using as as a column label causes the following example
to fail because the database server interprets as as identifying from as
a column label and thus finds no required FROM clause:
SELECT mycol as from mytab; -- fails
The following successful example repeats the AS keyword:
SELECT mycol AS as from mytab;
Using from as a column label causes the following example
to fail because the database server expects a table name to follow
the first from:
SELECT mycol from FROM mytab; -- fails
This example uses the AS keyword to identify the first from as
a column label:
SELECT mycol AS from FROM mytab;