17.05 - Example: EXPAND ON for a WEEK_BEGIN Anchor Point - 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)

This example expands employee using a WEEK_BEGIN anchor point.

Assume the following table definition.

     CREATE SET TABLE employee, NO FALLBACK (
       eid       INTEGER,
       ename     CHARACTER(20) CHARACTER SET LATIN NOT CASESPECIFIC,
       jobperiod PERIOD(DATE))
     PRIMARY INDEX (eid);

Table employee contains the following single row.

employee    
eid ename jobperiod
1001 Xavier 2008-06-02,2008-06-24

Expand employee by WEEK_BEGIN.

     SELECT eid, ename, BEGIN(expd) AS tsp
     FROM employee
     EXPAND ON jobperiod expd BY ANCHOR WEEK_BEGIN;

In this example, each expanded row value starts on a Monday because the week starts on a Monday.

employee    
eid ename tsp
1001 Xavier 2008-06-09
1001 Xavier 2008-06-16
1001 Xavier 2008-06-23