Example - Advanced SQL Engine - Teradata Database

SQL Functions, Expressions, and Predicates

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
Language
English (United States)
Last Update
2021-07-28
dita:mapPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/djk1612415574830.ditamap
dita:ditavalPath
SQL_Functions__Expressions__and_Predicates.Upload_071421/wrg1590696035526.ditaval
dita:id
B035-1145
lifecycle
previous
Product Category
Teradata Vantageā„¢

The following example calculates the 50-day moving average of the closing price of the stock for Zemlinsky Bros. Corporation. The ticker name for the company is ZBC.

   SELECT MarketDay, ClosingPrice, 
      MAVG(ClosingPrice,50, MarketDay) AS ZBCAverage
   FROM MarketDailyClosing
   WHERE Ticker = 'ZBC'
   ORDER BY MarketDay;

The results for the query might look something like the following table.

MarketDay ClosingPrice ZBCAverage
12/27/1999 89 1/16 85 1/2
12/28/1999 91 1/8 86 1/16
12/29/1999 92 3/4 86 1/2
12/30/1999 94 1/2 87