Example: Creating an Aggregate Join Index With a Nested Expression in its Select List - Advanced SQL Engine - Teradata Database

SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
wgr1555383704548.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1144
lifecycle
previous
Product Category
Teradata Vantage™

This example creates an aggregate join index with a nested expression in its select list.

     CREATE JOIN INDEX aji_extract_begin AS
       SELECT EXTRACT(MONTH FROM BEGIN(d1)) AS mth, SUM(b1) AS sumb 
       FROM t1 
       GROUP BY 1;

If you then submit a HELP JOIN INDEX request on aji_extract_begin, the system returns a report like the following:

     HELP JOIN INDEX aji_extract_begin;
Column Name                Type      Comment
-------------------------- --------- ---------------------
CountStar                  F         ?
mth                        I         ?
sumb                       F         ?

Similarly to Example: Creating a Join Index With a BEGIN Bound Function in its Select List and Example: Creating a Join Index with a Multicolumn CASE Expression in its Select List, column mth in this example can be used to map identical query expressions to the join index.