Example: EXPAND ON for a WEEK_BEGIN Anchor Point - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
Language
English (United States)
Last Update
2024-04-05
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantage™

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