Example: Expansion on an Anchor Point Using ANCHOR_SECOND - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

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

Create a table named t2 with the following definition.

     CREATE TABLE t2 (
       id       INTEGER
       quantity INTEGER
       pd       PERIOD(DATE))
       PRIMARY INDEX (id);

The input row for the example statement is of type TIMESTAMP and contains the following timestamp period data. (2011-01-01 10:15:20.000001, 2011-01-01 10:15:25.000009).

Submit the following SELECT statement on table t2.

     SELECT BEGIN(expd)
     FROM t2
     EXPAND ON pd AS expd BY ANCHOR ANCHOR_SECOND;

The result set contains 5 rows because the input row has a period of 5 seconds, beginning with 10:15:20.000001 and ending with 10:15:25.000009.

begin expd
2011-01-01 10:15:21.000000
2011-01-01 10:15:22.000000
2011-01-01 10:15:23.000000
2011-01-01 10:15:24.000000
2011-01-01 10:15:25.000000