Cumulative Moving Average - Teradata® Database

Database Analytic Functions

Product
Teradata® Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/wnd1589838592459.ditamap
dita:ditavalPath
Teradata_Vantage™___Advanced_SQL_Engine_Analytic_Functions.withLogo_upload_July2021/ayr1485454803741.ditaval
dita:id
B035-1206
lifecycle
previous
Product Category
Teradata Vantage™

In a cumulative moving average (CMA), the data are added to the data set in an ordered data stream over time. The objective is to compute the average of all the data at each point in time when new data arrived. A typical use case is an investor who wants to find the average price of all transactions of a specific stock over time, up to the current time.

With MAvgType ('C'), the MovingAverage function computes the arithmetic average of all the rows from the beginning of the series with this formula:

CMA = (V1 + V2 + ... + VN)/N

V i is a value. N is the number of rows from the beginning of the data set.