15.10 - AS - Teradata Database

Teradata Database SQL Data Types and Literals

prodname
Teradata Database
vrm_release
15.10
category
Programming Reference
featnum
B035-1143-151K

Assigns a temporary name to an expression.

where:

 

Syntax element …

Specifies …

value_expression

the expression to which a temporary name is to be assigned.

AS

an optional keyword indicating that the variable that follows is the temporary new name for value_expression.

name

the new temporary name for value_expression.

AS is ANSI SQL:2011 compliant.

The temporary name can be referenced elsewhere in the request.

Column headings (that is, TITLE) default to the newly assigned name. See “TITLE” on page 336.

This syntax allows the ORDER BY clause to include column names rather than positionally defining the sort columns. The AS keyword is not included when column_2 is renamed to second_value.

   SELECT COLUMN1 +100 AS first_value, column_2 second_value 
   FROM table_1
   WHERE second_value > 100 
   ORDER BY first_value;

This syntax creates a temporary named column and uses it in a WHERE clause.

   SELECT Name,((Salary + (YrsExp * 200))/12) AS Projection 
   FROM Employee
   WHERE DeptNo = 600 
   AND Projection < 2500;