You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

KQL使用top-nested按目的地统计Top3来源及对应路径总访问量

KQL实现按目的地分组取Top3来源并统计访问量

最优实现方案(partition算子)

TransportData
// 统计每个<目的地, 来源>路径的总访问量
| summarize TotalVisits = count() by Destination, Source
// 按目的地分组,每组内按访问量降序取前3条
| partition by Destination (
    top 3 by TotalVisits desc
)
// 可选:对最终结果按目的地、访问量排序,更易读
| order by Destination asc, TotalVisits desc

如果需要保留并列排名的来源,可以将top 3修改为top 3 with ties


基于top-nested的修正方案

你之前用top-nested没拿到总访问量是因为没有显式将计数赋值给对应字段,修正后写法如下:

TransportData
| top-nested of Destination by max(1), // 此处可指定目的地数量,如`top-nested 50 of Destination`
  top-nested 3 of Source by TotalVisits = count()
| project Destination, Source, TotalVisits

这个方案更适合目的地数量大的大数据量查询场景。


内容的提问来源于stack exchange,提问作者Edelweiss Peimann

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 21:36:01