I'm new to Kusto/KQL but experienced in T-SQL. I am trying to get a list of exceptions, group them by type, add a count, and order by that count descending. In SQL it would be:
SELECT Type, COUNT(Type)
FROM exceptions
GROUP BY Type
ORDER BY COUNT(Type) Desc
I've managed everything but the sort.
exceptions
| summarize count() by type
I cannot work out how to sort by an aggregate. I've tried | 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
CodePudding user response:
The default column name for count()
aggregation is count_
, so:
exceptions
| summarize count() by type
| sort by count_ desc
Or, with explicitly naming the column:
exceptions
| summarize CountExceptions = count() by type
| sort by CountExceptions desc