Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

anyHeavy

anyHeavy

引入版本:v1.1.0

使用 heavy hitters 算法选取一个高频值。 如果某个值在查询的每个执行线程中出现的次数都超过半数,则返回该值。 通常,结果是非确定性的。

语法

anyHeavy(column)

参数

返回值

返回一个高频值。该结果是非确定性的。Any

示例

使用示例

CREATE TABLE ontime (AirlineID UInt32) ENGINE = Memory;

-- Three quarters of the flights belong to one airline, so it occurs in more than half of the
-- rows seen by every thread and the result is the same on every run.
INSERT INTO ontime SELECT if(number % 4 = 0, 19393, 19690) FROM numbers(1000);

SELECT anyHeavy(AirlineID) AS res
FROM ontime;
┌───res─┐
│ 19690 │
└───────┘
Navigation