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

SQL Data Types and Literals

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
17.00
Published
June 2020
Language
English (United States)
Last Update
2021-01-22
dita:mapPath
zsn1556242031050.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1143
lifecycle
previous
Product Category
Teradata Vantageā„¢

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