Chaining Queries in Stream Analytics

c.mavi01 0 Reputation points

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.

Azure Stream Analytics
Azure Stream Analytics
An Azure real-time analytics service designed for mission-critical workloads.
342 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 31,106 Reputation points MVP

    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:

    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.

    0 comments No comments