2021-02-02 12:00:41 +00:00
|
|
|
|
---
|
2022-08-26 19:07:59 +00:00
|
|
|
|
slug: /zh/sql-reference/aggregate-functions/reference/anyheavy
|
2022-04-10 23:08:18 +00:00
|
|
|
|
sidebar_position: 103
|
2021-02-02 12:00:41 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# anyHeavy {#anyheavyx}
|
|
|
|
|
|
2022-09-28 12:21:58 +00:00
|
|
|
|
选择一个频繁出现的值,使用[heavy hitters](https://doi.org/10.1145/762471.762473) 算法。 如果某个值在查询的每个执行线程中出现的情况超过一半,则返回此值。 通常情况下,结果是不确定的。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
anyHeavy(column)
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
**参数**
|
|
|
|
|
|
2021-03-17 13:06:35 +00:00
|
|
|
|
- `column` – The column name。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
**示例**
|
|
|
|
|
|
2021-02-05 04:14:07 +00:00
|
|
|
|
使用 [OnTime](../../../getting-started/example-datasets/ontime.md) 数据集,并选择在 `AirlineID` 列任何频繁出现的值。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-03-24 15:46:03 +00:00
|
|
|
|
查询:
|
|
|
|
|
|
2021-02-02 12:00:41 +00:00
|
|
|
|
``` sql
|
|
|
|
|
SELECT anyHeavy(AirlineID) AS res
|
2021-03-24 15:46:03 +00:00
|
|
|
|
FROM ontime;
|
2021-02-02 12:00:41 +00:00
|
|
|
|
```
|
|
|
|
|
|
2021-03-24 15:46:03 +00:00
|
|
|
|
结果:
|
|
|
|
|
|
2021-02-02 12:00:41 +00:00
|
|
|
|
``` text
|
|
|
|
|
┌───res─┐
|
|
|
|
|
│ 19690 │
|
|
|
|
|
└───────┘
|
|
|
|
|
```
|