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
| Name | Description |
|---|---|
| N | Number of distinct values to return (Max 2000) |
| ValueColumn | Column whose frequent values are returned |
| SummingExpression | Optional 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) |
|---|---|
| Bjorn | 2 |
| Ragnar | 3 |
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) |
|---|---|
| Lindisfarne | 1100 |
| Paris | 1600 |