Example

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

brand
Software
Teradata Vantage
prodname
Teradata Database
Teradata Vantage NewSQL Engine
vrm_release
16.20
category
Programming Reference
featnum
B035-1145-162K

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,
   SUM(a1.price)
   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);