简体   繁体   English

在 Azure Stream 分析中查找在 5 分钟内出现至少 3 分钟的查询数

[英]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.

相关问题 使用 BY TIMESTAMP 的带有滚动窗口的 Azure 流分析查询在测试中运行良好,但在运行作业结果时关闭 - Azure Stream Analytics query with tumbling window using BY TIMESTAMP works fine on test but is off in running job results Azure 流分析作业将两个事件中心之间不匹配记录的输出延迟了 1 分钟 - Azure Stream Analytics Job delayed output of not matching records by 1 minutes between two event hubs 用 datediff 和 substring 计算分钟数 - Count the number of minutes with datediff and substring DateDiff以分钟为单位查找持续时间不起作用 - DateDiff to find duration in minutes not working 使用DateDiff查找持续时间(分钟) - using DateDiff to find duration in minutes Azure Stream 分析 - SQL - Azure Stream Analytics - SQL 在规定的时间范围内计算分钟? - Calculating minutes within a defined time window? 我如何才能找到确切的分钟数,而无需在SQL Server中的两个日期之间取整 - How can I find exact number of minutes without rounding between two dates in sql server 查找未接来电30分钟内客户服务部门完成的回电话数 - Find the number of return calls that were done by customer care within 30 minutes of the missed call 如何从日期时间获得平均分钟数? - How to get the average number of minutes from datetime?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM