If else condition in stream analytics query

Category: azure stream analytics


devSus on Tue, 17 Apr 2018 10:25:00


I want to process IOT hub input data conditionally ie. based on type of message. So i need to process data in terms of if-else conditions. How can i write if-else statement in stream analytics query?


Alex Raizman - MSFT on Tue, 17 Apr 2018 16:58:34

You can use CASE ... WHEN expression as described here.

JasonHowell on Tue, 17 Apr 2018 21:20:33

Another pattern is to use two separate queries (in the same job if needed, or separate job for more isolation) doing the conditional logic in the where clause:

SELECT <columns>

INTO output1

FROM input

WHERE <condition1>

SELECT <columns>

INTO output2

FROM input

WHERE <condition2>