This example computes the triangular moving average for the price of stock.
MovingAverage SQL Call for Triangular Moving Average
SELECT * FROM MovingAverage ( ON company1_stock PARTITION BY name ORDER BY period USING MAvgType ('T') TargetColumns ('stockprice') WindowSize (10) IncludeFirst ('true') ) AS dt ORDER BY id;
MovingAverage Output for Triangular Moving Average
id | name | period | stockprice | stockprice_tmavg |
---|---|---|---|---|
1 | Company1 | 1961-05-17 00:00:00.000000 | 460.000000000000 | 460.000000000000 |
2 | Company1 | 1961-05-18 00:00:00.000000 | 457.000000000000 | 459.250000000000 |
3 | Company1 | 1961-05-19 00:00:00.000000 | 452.000000000000 | 458.277777777778 |
4 | Company1 | 1961-05-22 00:00:00.000000 | 459.000000000000 | 457.958333333333 |
5 | Company1 | 1961-05-23 00:00:00.000000 | 462.000000000000 | 457.966666666667 |
6 | Company1 | 1961-05-24 00:00:00.000000 | 459.000000000000 | 458.000000000000 |
7 | Company1 | 1961-05-25 00:00:00.000000 | 463.000000000000 | 457.777777777778 |
8 | Company1 | 1961-05-26 00:00:00.000000 | 479.000000000000 | 458.416666666667 |
9 | Company1 | 1961-05-29 00:00:00.000000 | 493.000000000000 | 460.555555555556 |
10 | Company1 | 1961-05-31 00:00:00.000000 | 490.000000000000 | 463.444444444444 |
11 | Company1 | 1961-06-01 00:00:00.000000 | 492.000000000000 | 467.000000000000 |
12 | Company1 | 1961-06-02 00:00:00.000000 | 498.000000000000 | 471.611111111111 |
13 | Company1 | 1961-06-05 00:00:00.000000 | 499.000000000000 | 477.138888888889 |
14 | Company1 | 1961-06-06 00:00:00.000000 | 497.000000000000 | 482.555555555556 |
15 | Company1 | 1961-06-07 00:00:00.000000 | 496.000000000000 | 486.916666666667 |
16 | Company1 | 1961-06-08 00:00:00.000000 | 490.000000000000 | 490.416666666667 |
17 | Company1 | 1961-06-09 00:00:00.000000 | 489.000000000000 | 493.000000000000 |
18 | Company1 | 1961-06-12 00:00:00.000000 | 478.000000000000 | 493.944444444444 |
19 | Company1 | 1961-06-13 00:00:00.000000 | 487.000000000000 | 493.555555555556 |
20 | Company1 | 1961-06-14 00:00:00.000000 | 491.000000000000 | 492.500000000000 |
21 | Company1 | 1961-06-15 00:00:00.000000 | 487.000000000000 | 491.111111111111 |
22 | Company1 | 1961-06-16 00:00:00.000000 | 482.000000000000 | 489.500000000000 |
23 | Company1 | 1961-06-19 00:00:00.000000 | 479.000000000000 | 487.694444444444 |
24 | Company1 | 1961-06-20 00:00:00.000000 | 478.000000000000 | 486.444444444444 |
25 | Company1 | 1961-06-21 00:00:00.000000 | 479.000000000000 | 485.305555555556 |