如何在 Kusto 中的汇总中添加额外列

Ahm*_*mad 5 kql azure-data-explorer

我是 Kusto 的新手,我正在尝试使用summarize可以指定要显示要分组的值的其他列的位置进行分组。

这就是我想要做的,在标准 SQL 中提到:

select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType != 'Success'
group by UserId
order by ErrorCount desc
Run Code Online (Sandbox Code Playgroud)

我按 分组UserId,但随后我也在分组结果中显示LocationIdUserId

将上面的内容转换为 Kusto,我写的是:

SampleTable
| where ResultType != "Success"
| summarize ErrorCount=count() by UserId
| project UserId, LocationId, ErrorCount
| sort by ErrorCount desc
Run Code Online (Sandbox Code Playgroud)

但这不起作用。Kusto 抱怨说它无法确定是否LocationId在第四行。我使用 Kusto 的explain关键字验证了我正在编写正确的 Kusto 查询。所以有什么问题 ?

Yon*_*i L 5

如果您想将其LocationId作为聚合键之一,则应将其包含在对 的调用中summarize,如下所示:| summarize ErrorCount = count() by UserId, LocationId

[否则,请澄清您期望的输出模式(理想情况下,除了提供示例输入数据集外,还使用运算datatable符:数据表运算符