Primeros pasos o instrucciones para empezar a usar Microsoft Q&A
Hi Augusto Piva,
Thanks for the answer, if the code you provided does not work and it looks okay to you, there might be an issue with the data or a bug in the Stream Analytics service. In that case, you might want to reach out to Azure support for further assistance.
Now, for your other question, the WHERE clause in your query can indeed affect the results of the TopOne function with the WHEN clause. For example, if you have a WHERE clause that filters out certain rows, those rows will not be available for the TopOne function to consider, even if they would have met the WHEN condition so you can try the following:
SELECT
deviceId,
TopOne(fieldA) OVER (PARTITION BY deviceId ORDER BY timestamp DESC WHEN fieldA > 0) AS firstFieldA,
TopOne(fieldB) OVER (PARTITION BY deviceId ORDER BY timestamp DESC WHEN fieldB IS NOT NULL) AS newEnergyValue
FROM eventHub
WHERE someCondition = true
GROUP BY
deviceId,
HoppingWindow(Duration(day, 1), Hop(minute, 15))
I hope the information provided this time was useful.
Regards,
Gao
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".