Example: Using the TITLE Phrase in a SELECT Statement

Teradata Vantageā„¢ Data Types and Literals

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1143-162K

When a title is specified at column creation time, note that the defined column name, not the title name, must be specified in statements that access the column. For example, to retrieve the total hours worked on each project by user Peterson, the project column must be referenced:

SELECT Proj_Id, SUM(Hours)
FROM CHARGES
WHERE EmpNo = 10001
GROUP BY Proj_Id ORDER BY Proj_Id ;

The returned report, however, uses the following title headings:

 Project
      Id     Sum(Hours)
--------     ----------
PAY-0001            9.5
PAY-0002           34.5

A TITLE phrase also can be given in the retrieval statement to override a default title.

For example, in the following SELECT statement, a TITLE phrase provides a more descriptive heading for the DOB column.

SELECT Name, DOB (TITLE 'Birthdate')
FROM Employee;

This statement returns:

Name         Birthdate
--------     ---------
Smith T       51/10/31
Newman P      56/08/29
Omura H       54/04/24
   .            .
   .            .

The multiline TITLE definition in this statement:

SELECT Name, DOB (TITLE 'Date//Of//Birth')
FROM Employee;

returns:

                Date
                  Of
Name           Birth
--------    --------
Smith T     51/10/31
Newman P    56/08/29
Omura H     54/04/24
   .           .
   .           .