> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 返回指定列中近似最常见的值及其计数组成的数组。

# approx_top_sum

<div id="approx_top_sum">
  ## approx\_top\_sum
</div>

版本引入：v1.1.0

返回由指定列中近似最常见的值及其计数组成的数组。
结果数组按值的近似出现频率降序排序 (而非按值本身排序) 。
此外，还会将值的权重纳入考虑。

此函数不保证结果一定准确。
在某些情况下，可能会出现误差，并返回出现频繁但并非最频繁的值。

**另请参见**

* [topK](/zh/reference/functions/aggregate-functions/topK)
* [topKWeighted](/zh/reference/functions/aggregate-functions/topKWeighted)
* [approx\_top\_k](/zh/reference/functions/aggregate-functions/approxtopk)

**语法**

```sql theme={null}
approx_top_sum(N[, reserved])(column, weight)
```

**参数**

* `N` — 要返回的元素个数。可选。默认值：10。[`UInt64`](/zh/reference/data-types/int-uint)
* `reserved` — 可选。指定为值预留的槽位数。如果 `uniq(column) > reserved`，topK 函数的结果将是近似值。默认值：`N * 3`。`N` 的最大值为 65536。[`UInt64`](/zh/reference/data-types/int-uint)

**参数**

* `column` — 要查找出现频率最高值的列名。[`String`](/zh/reference/data-types/string)
* `weight` — 权重。在频率计算中，每个值会按 `weight` 次计入。[`UInt64`](/zh/reference/data-types/int-uint)

**返回值**

返回一个数组，其中包含近似最常见的值及其计数，并按近似频率降序排序。[`Array`](/zh/reference/data-types/array)

**示例**

**使用示例**

```sql title=Query theme={null}
SELECT approx_top_sum(2)(k, w)
FROM VALUES('k Char, w UInt64', ('y', 1), ('y', 1), ('x', 5), ('y', 1), ('z', 10));
```

```response title=Response theme={null}
┌─approx_top_sum(2)(k, w)─┐
│ [('z',10,0),('x',5,0)]  │
└─────────────────────────┘
```

**另请参阅**

* [topK](/zh/reference/functions/aggregate-functions/topK)
* [topKWeighted](/zh/reference/functions/aggregate-functions/topKWeighted)
* [approx\_top\_k](/zh/reference/functions/aggregate-functions/approxtopk)
