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.