azure-stream-analyticsstream-analytics

Azure Stream Analytics Query - get last request for all device


I have IoT Hub, it collects messages from many devices. Data from IoT Hub are sent to stream analytics, and now I would like to stream analytics, display a list of all devices along with the last request. That is, a table in which there are eg 10 devices and with each device its last request.

My actual code:

SELECT
       deviceId,
       param1 as humidity,
       param2 as temperature,
       datetime as data
FROM hubMessage 
GROUP By deviceId, data,temperature,humidity, 
TumblingWindow(minute,5)

Ont this query i have error on deviceId:

GROUP BY with no aggregate expressions is not supported.

I dont'h have any idea, how resolve my problem with not supported expression and change last request for all device ;/


Solution

  • GROUP BY with no aggregate expressions is not supported.

    According to this error message,you need to use group by with aggregate expression.All aggregate expressions supported by ASA are listed here.

    If you want to get the latest request,i think the TopOne is suitable for you.

    enter image description here

    If you want to select all the data match the filter,maybe you could use COUNT with group by.