> ## 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](/ja/reference/functions/aggregate-functions/topK)
* [topKWeighted](/ja/reference/functions/aggregate-functions/topKWeighted)
* [approx\_top\_k](/ja/reference/functions/aggregate-functions/approxtopk)

**構文**

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

**パラメータ**

* `N` — 返す要素数。省略可能。デフォルト値: 10。[`UInt64`](/ja/reference/data-types/int-uint)
* `reserved` — 省略可能。値のために予約するセル数を指定します。`uniq(column) > reserved` の場合、topK 関数の結果は近似値になります。デフォルト値: `N * 3`。`N` の最大値は 65536 です。[`UInt64`](/ja/reference/data-types/int-uint)

**引数**

* `column` — 最も頻出する値を見つける対象のカラム名。[`String`](/ja/reference/data-types/string)
* `weight` — 重み。頻度計算では、各値は `weight` 回出現したものとして集計されます。[`UInt64`](/ja/reference/data-types/int-uint)

**戻り値**

近似頻度の高い順にソートされた、概ね最も頻出する値とその出現回数の配列を返します。[`Array`](/ja/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](/ja/reference/functions/aggregate-functions/topK)
* [topKWeighted](/ja/reference/functions/aggregate-functions/topKWeighted)
* [approx\_top\_k](/ja/reference/functions/aggregate-functions/approxtopk)
