Example: Using the TITLE Phrase in a SELECT Statement - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
Language
English (United States)
Last Update
2024-04-03
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

When a title is specified at column creation time, 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
   .           .
   .           .