MAVG Usage Notes - Teradata Vantage

Teradata® VantageCloud Lake

Deployment
VantageCloud
Edition
Lake
Product
Teradata Vantage
Published
January 2023
ft:locale
en-US
ft:lastEdition
2024-12-11
dita:mapPath
phg1621910019905.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
phg1621910019905

Using AVG Instead of MAVG

The use of MAVG is strongly discouraged. MAVG is a Teradata extension to the ANSI SQL:2011 standard, and is equivalent to the ANSI-compliant AVG window function that specifies ROWS value PRECEDING as its aggregation group. MAVG is retained only for backward compatibility with existing applications.

MAVG and Missing Data Points

Make sure that data you analyze using MAVG has no missing data points. Computing a moving average over data with missing points produces unexpected and incorrect results because the computation considers n physical rows of data rather than n logical data points.

Computing the Moving Average When Number of Rows is Less Than width

For the (possibly grouped) resulting relation, the moving average considering width rows is computed where the rows are sorted by the sort_expression list.

When there are fewer than width rows, the average is computed using the current row and all preceding rows.