Example: Expansion on an Anchor Point Using ANCHOR_SECOND - Teradata Database - Teradata Vantage NewSQL Engine

SQL Data Manipulation Language

Product
Teradata Database
Teradata Vantage NewSQL Engine
Release Number
16.20
Published
March 2019
Language
English (United States)
Last Update
2019-05-03
dita:mapPath
fbo1512081269404.ditamap
dita:ditavalPath
TD_DBS_16_20_Update1.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