Azure Stream Analytics
An Azure real-time analytics service designed for mission-critical workloads.
342 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
How can I write multiple SQL queries where the output of one query serves as the input to the next query, and this process repeats for several levels? I am working with around 3 or more levels of queries.
Hello @c.mavi01 ,
welcome to this moderated Azure community forum.
If you want to write queries to be reuse, check the WITH clause.
Example from that site:
WITH
NormalReadings AS
(
SELECT *
FROM Sensor
WHERE Reading < 100 AND Reading > 0
),
Averages AS
(
SELECT SensorId, AVG(Reading) as AvgNormalReading
FROM NormalReadings
GROUP BY SensorId, TumblingWindow(minute, 1)
),
BadAverages AS
(
SELECT *
FROM Averages
WHERE AvgNormalReadings < 10
)
SELECT * INTO outputAlerts FROM BadAverages
SELECT * INTO outputLog FROM NormalReadings
If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.