Reputation: 247
I would like to calculate the rate of change between the two following values in my stream:
The only thing I can't find in the documentation is how to create a "delayed" sliding window, meaning that it begins 2mn before and ends 1mn before the actual time so I can make some calculations such as the rate of change.
Upvotes: 0
Views: 284
Reputation: 1306
You can do it two steps.
Something like below
WITH OneMinuteWindows AS
(
SELECT
Avg(Column1) AvgValue
FROM
InputEventHub
GROUP BY
TumblingWindow(mi, 1)
)
SELECT
System.TimeStamp [TimeStamp],
AvgValue [CurrentValue],
LAG(AvgValue) OVER (LIMIT DURATION(mi, 2)) [PreviousValue]
FROM
OneMinuteWindows
Upvotes: 1