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

在最小化 ExprToMinimize 的组中查找行,并返回 ExprToReturn 的值(或使用 * 返回整个行) 。Finds a row in the group that minimizes ExprToMinimize , and returns the value of ExprToReturn (or * to return the entire row).

  • 只能在 summarize 内的聚合上下文中使用Can be used only in context of aggregation inside summarize

语法Syntax

summarize [(NameExprToMinimize , NameExprToReturn [, ...] )=] arg_min (ExprToMinimize, * | ExprToReturn [, ...]) summarize [(NameExprToMinimize , NameExprToReturn [, ...] )=] arg_min (ExprToMinimize , * | ExprToReturn [, ...])

参数Arguments

  • ExprToMinimize:用于聚合计算的表达式。ExprToMinimize : Expression that will be used for aggregation calculation.
  • ExprToReturn:当 ExprToMinimize 为最小值时,用于返回值的表达式。ExprToReturn : Expression that will be used for returning the value when ExprToMinimize is minimum. 要返回的表达式可以是通配符 (*),用于返回输入表的所有列。Expression to return may be a wildcard (*) to return all columns of the input table.
  • NameExprToMinimize:表示 ExprToMinimize 的结果列的可选名称。NameExprToMinimize : An optional name for the result column representing ExprToMinimize .
  • NameExprToReturn:表示 ExprToReturn 的结果列的其他可选名称。NameExprToReturn : Additional optional names for the result columns representing ExprToReturn .

返回Returns

在最小化 ExprToMinimize 的组中查找行,并返回 ExprToReturn 的值(或使用 * 返回整个行) 。Finds a row in the group that minimizes ExprToMinimize , and returns the value of ExprToReturn (or * to return the entire row).

示例Examples

显示每个产品的最低价供应商:Show cheapest supplier of each product:

Supplies | summarize arg_min(Price, Supplier) by Product

显示所有详细信息,而不仅仅是供应商名称:Show all the details, not just the supplier name:

Supplies | summarize arg_min(Price, *) by Product

找到每个大洲最南端的城市及其所属的国家/地区:Find the southernmost city in each continent, with its country:

PageViewLog 
| summarize (latitude, min_lat_City, min_lat_country)=arg_min(latitude, City, country) 
    by continent

Arg min