Berserk Docs
Tabular OperatorsAggregate Operators

top-hitters

Returns an approximation of the most frequent (or, with a by-clause, the largest-sum) values of a column.

Returns an approximation of the most frequent (or, with a by-clause, the largest-sum) values of a column. Use top-hitters only when approximate results are acceptable; for exact results use summarize followed by top.

Syntax

top-hitters N of ValueColumn [by SummingExpression]

Approximate top-N of the most frequent values, optionally ranked by a summed expression

Parameters

NameDescription
NNumber of distinct values to return (Max 2000)
ValueColumnColumn whose frequent values are returned
SummingExpressionOptional expression whose sum is used to rank values instead of occurrence count

Examples

Example 1

datatable(jarl:string)[
  "Ragnar",
  "Bjorn",
  "Ragnar",
  "Lagertha",
  "Bjorn",
  "Ragnar"
]
| top-hitters 2 of jarl
jarl (string)approximate_count_jarl (long)
Bjorn2
Ragnar3

Example 2

datatable(target:string, silver:long)[
  "Lindisfarne", 800,
  "Paris", 1200,
  "York", 600,
  "Paris", 400,
  "Lindisfarne", 300
]
| top-hitters 2 of target by silver
target (string)approximate_sum_target (long)
Lindisfarne1100
Paris1600

On this page