17.10 - Example: Using the TITLE Phrase in a SELECT Statement - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
July 2021
Content Type
Programming Reference
Publication ID
B035-1143-171K
Language
English (United States)

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
   .           .
   .           .