17.10 - MovingAverage例: 累積移動平均 - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - Advanced SQL Engine分析関数

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Release Date
2021年7月
Content Type
プログラミング リファレンス
Publication ID
B035-1206-171K-JPN
Language
日本語 (日本)

次の使用例は、株価の累積移動平均を計算します。

入力

<MovingAverage Examples入力>を参照してください。

SQL呼び出し

SELECT * FROM MovingAverage (
  ON company1_stock PARTITION BY name ORDER BY period
  USING
  MAvgType ('C')
  TargetColumns ('stockprice')
) AS dt ORDER BY id;

出力

id Name PERIOD stockprice stockprice_cmavg
1 Company1 1961-05-17 00:00:00.000000 460.000000000000 460.000000000000
2 Company1 1961-05-18 00:00:00.000000 457.000000000000 458.500000000000
3 Company1 1961-05-19 00:00:00.000000 452.000000000000 456.333333333333
4 Company1 1961-05-22 00:00:00.000000 459.000000000000 457.000000000000
5 Company1 1961-05-23 00:00:00.000000 462.000000000000 458.000000000000
6 Company1 1961-05-24 00:00:00.000000 459.000000000000 458.166666666667
7 Company1 1961-05-25 00:00:00.000000 463.000000000000 458.857142857143
8 Company1 1961-05-26 00:00:00.000000 479.000000000000 461.375000000000
9 Company1 1961-05-29 00:00:00.000000 493.000000000000 464.888888888889
10 Company1 1961-05-31 00:00:00.000000 490.000000000000 467.400000000000
11 Company1 1961-06-01 00:00:00.000000 492.000000000000 469.636363636364
12 Company1 1961-06-02 00:00:00.000000 498.000000000000 472.000000000000
13 Company1 1961-06-05 00:00:00.000000 499.000000000000 474.076923076923
14 Company1 1961-06-06 00:00:00.000000 497.000000000000 475.714285714286
15 Company1 1961-06-07 00:00:00.000000 496.000000000000 477.066666666667
16 Company1 1961-06-08 00:00:00.000000 490.000000000000 477.875000000000
17 Company1 1961-06-09 00:00:00.000000 489.000000000000 478.529411764706
18 Company1 1961-06-12 00:00:00.000000 478.000000000000 478.500000000000
19 Company1 1961-06-13 00:00:00.000000 487.000000000000 478.947368421053
20 Company1 1961-06-14 00:00:00.000000 491.000000000000 479.550000000000
21 Company1 1961-06-15 00:00:00.000000 487.000000000000 479.904761904762
22 Company1 1961-06-16 00:00:00.000000 482.000000000000 480.000000000000
23 Company1 1961-06-19 00:00:00.000000 479.000000000000 479.956521739130
24 Company1 1961-06-20 00:00:00.000000 478.000000000000 479.875000000000
25 Company1 1961-06-21 00:00:00.000000 479.000000000000 479.840000000000