[英]Find number of queries that appear at least 3 minutes in 5 minutes tumbling window in Azure Stream Analytics
I need to find clients that appear at least 3 minutes in 5 minutes Tumbling window in Azure Stream Analytics.我需要在 Azure Stream Analytics 中找到在 5 分钟内出现至少 3 分钟的客户。
Below code can find the number of people appear in 5 minutes window.下面的代码可以找到 5 分钟内出现的人数 window。
SELECT
apMac,
COUNT(Distinct([clientMac])) AS [numberofClientsPerFiveMinutes],
AVG(rssi) AS [rssiAverage],
System.TimeStamp AS [EventTimestampUTC],
UDF.melbournetime(System.TimeStamp) AS [EventTimestampLocalTime]
INTO [meraki-aggregated-powerbi]
FROM [ExplodedData]
GROUP BY apMac,
TumblingWindow(Minute, 5)
However, I want to count the people that have been in this list for at least 3 minutes.但是,我想计算在此列表中至少存在 3 分钟的人。 Using their first appearance and last appearance (base on their query time).
使用他们的第一次出现和最后一次出现(基于他们的查询时间)。
The problem is that I'm not aware of a code style in Stream Analytics问题是我不知道 Stream Analytics 中的代码样式
I found the solution with DATEDIFF as below.我找到了 DATEDIFF 的解决方案,如下所示。 You need to group by a person and then subtract the maximum from its minimum seen time.
您需要按一个人分组,然后从其最短观看时间中减去最大值。
SELECT
apmac,
COUNT(DISTINCT ([clientmac])) AS [SeenPassengerNumberInTimeRange],
ABS(DATEDIFF(MINUTE, MAX(seenTimeLocal), MIN(seenTimeLocal))) AS RangeTimeMinute,
EventTimestampLocalTime AS EventTimestampLocalDateTime
FROM [explodeddata]
GROUP BY
apmac,
EventTimestampLocalTime,
Tumblingwindow(minute, 5) -- 5 min window size
HAVING
ABS(DATEDIFF(MINUTE, MAX(seenTimeLocal), MIN(seenTimeLocal))) >= 2 -- at least 2 min
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.