Azure data explorer 如何在Kusto中的Summary中添加额外列
我是Kusto的新手,我正在尝试使用Azure data explorer 如何在Kusto中的Summary中添加额外列,azure-data-explorer,kql,Azure Data Explorer,Kql,我是Kusto的新手,我正在尝试使用summary进行分组,在这里,我可以为要分组的值指定要显示的其他列 这就是我试图做的,在标准SQL中提到: select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType != 'Success' group by UserId order by ErrorCount desc 我是按UserId进行分组的,但随后我也在分组结果中显示该UserId的Lo
summary
进行分组,在这里,我可以为要分组的值指定要显示的其他列
这就是我试图做的,在标准SQL中提到:
select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType != 'Success'
group by UserId
order by ErrorCount desc
我是按UserId
进行分组的,但随后我也在分组结果中显示该UserId
的LocationId
将上述内容转换为Kusto,我写下以下内容:
SampleTable
| where ResultType != "Success"
| summarize ErrorCount=count() by UserId
| project UserId, LocationId, ErrorCount
| sort by ErrorCount desc
但它不起作用。Kusto抱怨说,它无法确定was
LocationId
是否在第四行。我使用Kusto的explain
关键字验证了我正在编写正确的Kusto查询。那么问题出在哪里呢?如果您想将LocationId
作为聚合键之一,您应该将其包含在对汇总
的调用中,如下所示:|汇总ErrorCount=count(),按UserId,LocationId
[否则,请澄清您期望的输出模式(理想情况下,在提供示例输入数据集的同时,使用
datatable
运算符:如果希望将LocationId
作为聚合键之一,则应将其包含在对summary
的调用中,如下所示:| summary ErrorCount=count(),按UserId,LocationId
)
[否则,请澄清您期望的输出模式(理想情况下,在提供示例输入数据集的同时,使用
datatable
操作符:只是对原始SQL代码的友好提示
select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType !=
'Success'
group by UserId
order by ErrorCount desc
其中可能包含错误:
GROUP BY子句中缺少LocationId
正确的SQL代码应为:
select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType !=
'Success'
group by UserId, LocationId
order by ErrorCount desc
我认为这可能是您在Kusto代码中不小心从summary子句中漏掉LocationId的原因。只是对原始SQL代码的友好提醒
select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType !=
'Success'
group by UserId
order by ErrorCount desc
其中可能包含错误:
GROUP BY子句中缺少LocationId
正确的SQL代码应为:
select UserId, LocationId, COUNT(*) as ErrorCount from SampleTable where ResultType !=
'Success'
group by UserId, LocationId
order by ErrorCount desc
我想这可能是您在Kusto代码的summary子句中意外漏掉LocationId的原因。这让我的梦想成真。谢谢!这让我的梦想成真。谢谢!