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

如何去除Kusto查询返回结果中的重复数据行?

Kusto查询去重保留单条相同记录

原始查询及结果

执行的Kusto查询语句:

database
|where sourceServiceName_s == ("xyz")
|where TimeGenerated between(datetime(2024-11-01) .. datetime(2024-12-03))
|take 1000

查询返回结果:

Row 1 : AAA
Row 2 : AAA

需求:仅保留一行包含AAA数据的记录。

解决方案

根据需求,有几种常用的处理方式:

方式1:全局去重(所有列维度)

使用distinct *运算符去除完全重复的记录,确保每条记录唯一:

database
|where sourceServiceName_s == ("xyz")
|where TimeGenerated between(datetime(2024-11-01) .. datetime(2024-12-03))
|distinct *
|take 1000

方式2:指定列维度去重

如果只需针对显示AAA的特定列去重(比如该列名为targetColumn),可以指定列名:

database
|where sourceServiceName_s == ("xyz")
|where TimeGenerated between(datetime(2024-11-01) .. datetime(2024-12-03))
|distinct targetColumn
|take 1000

方式3:直接取第一条匹配记录

如果仅需获取任意一条包含AAA的记录,可先过滤后取第一条:

database
|where sourceServiceName_s == ("xyz")
|where TimeGenerated between(datetime(2024-11-01) .. datetime(2024-12-03))
|where targetColumn == "AAA"  // 替换为实际列名
|take 1

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.15 06:22:37