arg_min() (彙總函式)

在群組中尋找可最小化 ExprToMinimize 的數據列。

注意

此函式會與 summarize 運算子搭配使用。

已被取代的別名: argmin ()

語法

arg_min(ExprToMinimize,* | ExprToReturn [, ...])

深入瞭解 語法慣例

參數

名稱 類型 必要 Description
ExprToMinimize string ✔️ 用於匯總計算的表達式。
ExprToReturn string ✔️ ExprToMinimize 為最小值時,用來傳回值的表達式。 使用通配符 (*) 傳回輸入數據表的所有數據行。

Null 處理

當群組中所有資料列的 ExprToMinimize 為 null,則會挑選群組中的一個資料列。 否則會忽略 ExprToMinimize 為 null 的資料列。

傳回

傳回群組中的數據列,以最小化 ExprToMinimizeExprToReturn的值。 使用或 * 傳回整個數據列。

範例

在每個狀態中尋找 storm 事件的最小緯度。

StormEvents 
| summarize arg_min(BeginLat, BeginLocation) by State

顯示的結果數據表只包含前10個數據列。

狀態 BeginLat BeginLocation
美屬薩摩亞 -14.3 PAGO PAGO
加利福尼亞州 32.5709 內斯特
明尼蘇達州 43.5 比奇洛
WASHINGTON 45.58 WASHOUGAL
喬治亞州 30.67 法戈
伊利諾州 37 開羅
佛羅里達州 24.6611 SUGARLOAF KEY
肯塔基州 36.5 榛子
德克薩斯州 25.92 布朗斯維爾
俄亥俄 38.42 南 PT
... ... ...

尋找第一次在顯示所有數據行的每個狀態中發生直接死事時。

StormEvents
| where DeathsDirect > 0
| summarize arg_min(StartTime, *) by State

顯示的結果數據表只包含前 10 個數據列和前 3 個數據行。

State StartTime EndTime ...
印第安那 2007-01-01T00:00:00Z 2007-01-22T18:49:00Z ...
佛羅里達州 2007-01-03T10:55:00Z 2007-01-03T10:55:00Z ...
內華達州 2007-01-04T09:00:00Z 2007-01-05T14:00:00Z ...
LOUISIANA 2007-01-04T15:45:00Z 2007-01-04T15:52:00Z ...
WASHINGTON 2007-01-09T17:00:00Z 2007-01-09T18:00:00Z ...
加利福尼亞州 2007-01-11T22:00:00Z 2007-01-24T10:00:00Z ...
奧克拉何馬州 2007-01-12T00:00:00Z 2007-01-18T23:59:00Z ...
密蘇里州 2007-01-13T03:00:00Z 2007-01-13T08:30:00Z ...
德克薩斯州 2007-01-13T10:30:00Z 2007-01-13T14:30:00Z ...
阿肯色州 2007-01-14T03:00:00Z 2007-01-14T03:00:00Z ...
... ... ... ...

下列範例示範 Null 處理。

datatable(Fruit: string, Color: string, Version: int) [
    "Apple", "Red", 1,
    "Apple", "Green", int(null),
    "Banana", "Yellow", int(null),
    "Banana", "Green", int(null),
    "Pear", "Brown", 1,
    "Pear", "Green", 2,
]
| summarize arg_min(Version, *) by Fruit

輸出

水果 版本 Color
Apple 1 紅色
Banana 黃色
Pear 1 Brown