Example: Inventory Status at the Beginning of Each Week in a Month - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

The following example shows the inventory status at the beginning of each week for the month of September, 2011 for each business calendar setting.

SEL Item, BEGIN(week_duration) AS WeekBegin, Inventory
FROM Inventory_Tbl
EXPAND ON Duration AS week_duration
BY ANCHOR WEEK_BEGIN;

Inventory_Tbl:

Item Duration Inventory
101 2011-09-01, 2011-09-05 12
101 2011-09-05, 2011-09-12 18
101 2011-09-12, 2011-09-18 15
101 2011-09-18, 2011-09-21 11

Sep-2011 Calendar:

S M T W T F S
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30  
SET SESSION CALENDAR = Teradata;
Item WeekBegin Inventory
101 2011-09-04 12
101 2011-09-11 18
101 2011-09-18 11
SET SESSION CALENDAR = ISO;
Item WeekBegin Inventory
101 2011-09-05 18
101 2011-09-12 15
101 2011-09-19 11
SET SESSION CALENDAR = Compatible;
Item WeekBegin Inventory
101 2011-09-03 12
101 2011-09-10 18
101 2011-09-17 15