I am trying to calculate Open, Low, High and Close values for stock prices using Azure Stream Analytics SQL.
I can get Min and Max fairly easily, but I am having difficulty figuring out how to calculate Open (FIRST) and Close (LAST) of a TumblingWindow.
I have found the documentation here (https://docs.microsoft.com/en-us/azure/stream-analytics/stream-analytics-stream-analytics-query-patterns) to do first and last but I cannot combine them into a single query.
Here's what I have:
SELECT
DateAdd(second,-5,System.TimeStamp) as WinStartTime,
system.TimeStamp as WinEndTime,
exchange,
Max(price) as H,
Min(price) as L,
Count(*) as EventCount
FROM [input1]
GROUP BY TumblingWindow(second, 5), exchange
I am not terribly advanced in SQL, but is there a way to combine this into a single query? Even with the use of subqueries.
Note: 5 seconds is just an example window I chose for testing.
