Include an AS clause to assign a name to a select term or to a table name. You can use this name elsewhere in the statement to reference the select term. The name is often referred to as an alias.
When you use the AS clause on a nonaggregate column, you can reference the name in WHERE, ORDER BY, GROUP BY, and HAVING clauses. When you use the AS clause on an aggregate column, you can reference the name only in an ORDER BY clause.
The name you define must be unique in the SELECT list.
Column aliases are returned as the column name. Computed columns, including group aggregates, that do not have a column alias specified are assigned a system-generated column name such as EXPR-1, EXPR-2, and so forth.
Examples
The AS clause in the following statement instructs Zen to assign the name Total to the select term SUM (Amount_Paid) and order the results by the total for each student:
SELECT Student_ID, SUM (Amount_Paid) AS Total
FROM Billing
GROUP BY Student_ID
ORDER BY Total
The keyword AS is optional when used for table aliases as in this next example. When you use the AS clause on a table name in a FROM clause, you can reference the name in a WHERE, ORDER BY, GROUP BY, and HAVING clause.