17.05 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1146-175K
Language
English (United States)
   SELECT level, param, 'GMKSA' (TITLE 'OWNER')
   FROM gmksa
   WHERE cycle = '03'
   UNION
   SELECT level, param, 'GMKSA CONTROL'
   FROM gmksa_control
   WHERE cycle = '03'
   ORDER BY 1, 2;

The query returns the following results set:

   ***QUERY COMPLETED. 5 ROWS FOUND. 3 COLUMNS RETURNED.
   LEVEL  PARAM  OWNER
   -----  -----  ----- 
   00     A      GMKSA
   00     T      GMKSA
   85     X      GMKSA
   SF     A      GMKSA
   SF     T      GMKSA

The first SELECT specifies GMKSA, which is CHAR(5)—that data type is then forced on the second SELECT. As a result, GMKSA_CONTROL entries are dropped because the first five characters are the same.

Because this query does not specify the ALL option, duplicate rows are dropped.