例: 四半期別の売上げ - 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

次の例では、ビジネス カレンダ設定ごとに四半期別の売上げをどのように計算するかを示します。

SEL QuarterNumber_Of_Year(Sale_Date) Quarter_No,
Item_Code, SUM(Sale_Amt) FROM Sales_Tbl
GROUP BY 1,2
ORDER BY 1,2;
SET SESSION calendar = ISO;
Quarter_No Item_Code SUM(Sale_Amt)
1 101 325
1 102 150
SET SESSION calendar = Teradata;
Quarter_No Item_Code SUM(Sale_Amt)
1 101 300
1 102 150
4 101 25
SET SESSION calendar = COMPATIBLE;
Quarter_No Item_Code SUM(Sale_Amt)
1 101 300
1 102 150
4 101 25
Sales_Tbl
Item_Code Sale_Amt Sale_Date
101 10 2008-12-30
101 15 2008-12-31
101 20 2009-01-01
101 25 2009-01-02
101 30 2009-01-03
101 35 2009-01-04
101 40 2009-01-05
101 45 2009-01-06
101 50 2009-01-07
101 55 2009-01-08
102 10 2009-01-01
102 20 2009-01-03
102 30 2009-01-05
102 40 2009-01-07
102 50 2009-01-09
Jan 2009 Calendar
S M T W T F S
  29 30 31 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 31