1.0 - 8.00 - SimpleMovAvg Example - Teradata Vantage

Teradata® Vantage Machine Learning Engine Analytic Function Reference

Product
Teradata Vantage
Release Number
1.0
8.00
Release Date
May 2019
Content Type
Programming Reference
Publication ID
B700-4003-098K
Language
English (United States)

This example computes a simple moving average for the price of stock.

Input

The input table is company1_stock, as in the CumulativeMovAvg Example.

SQL Call

SELECT * FROM SimpleMovAvg (
  ON company1_stock PARTITION BY name ORDER BY period
  USING
  TargetColumns ('stockprice')
  WindowSize (10)
  IncludeFirst ('true')
) AS dt ORDER BY period;

Output

id name period stockprice stockprice_mavg
1 Company1 1961-05-17 00:00:00 460  
2 Company1 1961-05-18 00:00:00 457  
3 Company1 1961-05-19 00:00:00 452  
4 Company1 1961-05-22 00:00:00 459  
5 Company1 1961-05-23 00:00:00 462  
6 Company1 1961-05-24 00:00:00 459  
7 Company1 1961-05-25 00:00:00 463  
8 Company1 1961-05-26 00:00:00 479  
9 Company1 1961-05-29 00:00:00 493  
10 Company1 1961-05-31 00:00:00 490 467.4
11 Company1 1961-06-01 00:00:00 492 470.59999999999997
12 Company1 1961-06-02 00:00:00 498 474.7
13 Company1 1961-06-05 00:00:00 499 479.4
14 Company1 1961-06-06 00:00:00 497 483.2
15 Company1 1961-06-07 00:00:00 496 486.59999999999997
16 Company1 1961-06-08 00:00:00 490 489.7
17 Company1 1961-06-09 00:00:00 489 492.3
18 Company1 1961-06-12 00:00:00 478 492.2
19 Company1 1961-06-13 00:00:00 487 491.59999999999997
20 Company1 1961-06-14 00:00:00 491 491.7
... ... ... ... ...