Example - Analytics Database - Teradata Vantage

SQL Functions, Expressions, and Predicates

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2024-01-12
dita:mapPath
obm1628111499646.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
kby1472250656485
lifecycle
latest
Product Category
Teradata Vantageā„¢

The following example computes the changing market volume week over week for the stock of company Horatio Parker Imports. The ticker name for the company is HPI.

   SELECT MarketWeek, WeekVolume, 
      MDIFF(WeekVolume,1,MarketWeek) AS HPIVolumeDiff
   FROM
   (SELECT MarketWeek, SUM(Volume) AS WeekVolume
   FROM MarketDailyClosing
   WHERE Ticker = 'HPI'
   GROUP BY MarketWeek)
   ORDER BY MarketWeek;

The result might look like the following table. Note that the first row is null for column HPIVolume Diff, indicating no previous row from which to compute a difference.

MarketWeek WeekVolume HPIVolumeDiff
11/29/1999 9817671 ?
12/06/1999 9945671 128000
12/13/1999 10099459 153788
12/20/1999 10490732 391273
12/27/1999 11045331 554599