MAVG Function Examples | Teradata Vantage - 17.10 - Example - Advanced SQL Engine - Teradata Database

Teradata Vantageā„¢ - SQL Functions, Expressions, and Predicates

Advanced SQL Engine
Teradata Database
Release Number
Release Date
July 2021
Content Type
Programming Reference
Publication ID
English (United States)

Compute the 7-day moving average of sales for product code 10 for each day in the month of October, 1996.

   SELECT cdate, itemID, MAVG(sumPrice, 7, date)
   FROM (SELECT a1.calendar_date, a1.itemID,
   FROM Sales a1
   WHERE a1.itemID=10 AND a1.calendar_date
   BETWEEN 96-10-01 AND 96-10-31
   GROUP BY a1.calendar_date, a1.itemID) AS T1(cdate,
   itemID, sumPrice);