count()(聚合函数)count() (aggregation function)

返回每个摘要组的记录数(如果没有分组就进行汇总,则返回总数)。Returns a count of the records per summarization group (or in total, if summarization is done without grouping).

  • 只能在 summarize 内的聚合上下文中使用Can be used only in context of aggregation inside summarize
  • 使用 countif 聚合函数仅对某些谓词返回 true 的记录进行计数。Use the countif aggregation function to count only records for which some predicate returns true.

语法Syntax

summarize count()summarize count()

返回Returns

返回每个摘要组的记录数(如果没有分组就进行汇总,则返回总数)。Returns a count of the records per summarization group (or in total, if summarization is done without grouping).

示例Example

从字母 W 开始对州中的事件进行计数:Counting events in states starting with letter W:

StormEvents
| where State startswith "W"
| summarize Count=count() by State
状态State 计数Count
西弗吉尼亚州WEST VIRGINIA 757757
怀俄明州WYOMING 396396
华盛顿州WASHINGTON 261261
威斯康星州WISCONSIN 18501850