15.10 - NAMED - 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 …

expression

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

NAMED

a keyword indicating that the variable that follows is the temporary new name for expression.

name

the new temporary name for expression.

NAMED is a Teradata extension to the ANSI SQL:2011 standard.

For ANSI compliance, use AS instead of NAMED. See “AS” on page 332.

The temporary name can be referenced elsewhere in the request. But it should not be the same as another column name of any table used in a query.

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

The keyword NAMED is required in Teradata syntax. The keyword AS is optional.

The NAMED clause is enclosed in parentheses immediately following the renamed column.

AS is the ANSI SQL:2011 syntax. Teradata syntax using the NAMED clause is supported for backward compatibility. Use AS in place of NAMED for ANSI compliance. See “AS” on page 332.

In the following SELECT statement, a NAMED phrase associates an arithmetic expression with the name “Projection” so that the calculated column can be more easily referenced in the WHERE clause and the heading (TITLE) in the report is more meaningful.

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

The ANSI syntax for this example is the same as used for Example 2 for the “AS” on page 332.