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

SQL Date and Time Functions and Expressions

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
2023-10-30
dita:mapPath
cpk1628111786971.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
pxz1544241488545
lifecycle
latest
Product Category
Teradata Vantageā„¢

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