Berserk Docs
Aggregate FunctionsArg

arg_max

Returns both the maximum value and the corresponding return expression from the row where the first expression is maximum.

Syntax

arg_max(maximize, return_expr)

Parameters

Prop

Type

Returns: any

Syntax

arg_max(maximize, return_expr)

Parameters

Prop

Type

Returns: any

Examples

Example 1

datatable(clan:string, warrior:string, voyages:long)[
  "Lothbrok", "Ragnar", 42,
  "Lothbrok", "Bjorn", 31,
  "Fairhair", "Harald", 25,
  "Lothbrok", "Ivar", 35
]
| summarize arg_max(voyages, warrior) by clan
clan (string)voyages (long)warrior (string)
Fairhair25Harald
Lothbrok42Ragnar

Example 2

datatable(region:string, raid:string, loot:long)[
  "England", "Lindisfarne", 500,
  "England", "York", 1200,
  "Francia", "Paris", 7000,
  "Francia", "Rouen", 3000
]
| summarize (best_loot, best_raid) = arg_max(loot, raid) by region
region (string)best_loot (long)best_raid (string)
England1200York
Francia7000Paris

On this page