例: 月の毎週初めの在庫ステータス - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQLの日付/時刻関数と式

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
2021年7月
Language
日本語
Last Update
2021-09-23
dita:mapPath
ja-JP/dzx1591742169550.ditamap
dita:ditavalPath
ja-JP/wrg1590696035526.ditaval
dita:id
B035-1211
Product Category
Software
Teradata Vantage

次の例では、ビジネス カレンダ設定ごとに2011年9月の毎週初めの在庫ステータスを表示します。

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