Last active
June 20, 2022 05:34
-
-
Save sjwaight/709879d562b58c206b938c48b232c5a7 to your computer and use it in GitHub Desktop.
Azure Stream Analytics query used to parse incoming data to make it ready for training Cognitive Services Anomaly Detector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
DATETIMEFROMPARTS (DATEPART(year,readtime), DATEPART(month,readtime), DATEPART(day,readtime), DATEPART(hour, readtime), DATEPART(minute, readtime), 30, 0) as 'timestamp', | |
temperature as value | |
INTO | |
[temperaturedatacsv] | |
FROM | |
[rawiotjsondata] | |
SELECT | |
DATETIMEFROMPARTS (DATEPART(year,readtime), DATEPART(month,readtime), DATEPART(day,readtime), DATEPART(hour, readtime), DATEPART(minute, readtime), 30, 0) as 'timestamp', | |
humidity as value | |
INTO | |
[humiditydatacsv] | |
FROM | |
[rawiotjsondata] | |
/* Parse values from both sensors and select the higher one. Does not allow for failure of one sensor, but works for our use case. */ | |
SELECT | |
DATETIMEFROMPARTS (DATEPART(year,readtime), DATEPART(month,readtime), DATEPART(day,readtime), DATEPART(hour, readtime), DATEPART(minute, readtime), 30, 0) as 'timestamp', | |
CASE | |
WHEN pm100atma < pm100atmb THEN pm100atmb | |
ELSE pm100atma | |
END as value | |
INTO | |
[pm10datacsv] | |
FROM | |
[rawiotjsondata] | |
/* Parse values from both sensors and select the higher one. Does not allow for failure of one sensor, but works for our use case. */ | |
SELECT | |
DATETIMEFROMPARTS (DATEPART(year,readtime), DATEPART(month,readtime), DATEPART(day,readtime), DATEPART(hour, readtime), DATEPART(minute, readtime), 30, 0) as 'timestamp', | |
CASE | |
WHEN pm25atma < pm25atmb THEN pm25atmb | |
ELSE pm25atma | |
END as value | |
INTO | |
[pm25datacsv] | |
FROM | |
[rawiotjsondata] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment