Kusto 按聚合排序,如计数

Red*_*Red 2 sorting aggregate kql azure-data-explorer

我是 Kusto/KQL 的新手,但在 T-SQL 方面经验丰富。我正在尝试获取异常列表,按类型对它们进行分组,添加计数,然后按该计数降序排列。在 SQL 中它将是:

SELECT Type, COUNT(Type)
FROM exceptions
GROUP BY Type
ORDER BY COUNT(Type) Desc
Run Code Online (Sandbox Code Playgroud)

除了那类以外,我什么都做到了。

exceptions
| summarize count() by type
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚如何按聚合排序。我试过了| sort by count() desc| sort by count() by type desc| as c | sort by c desc| extend c = summarize count() by type | sort by c desc

小智 6

聚合的默认列名称count()count_,因此:

exceptions
| summarize count() by type
| sort by count_ desc
Run Code Online (Sandbox Code Playgroud)

或者,明确命名该列:

exceptions
| summarize CountExceptions = count() by type
| sort by CountExceptions desc
Run Code Online (Sandbox Code Playgroud)