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

> 指定したカラムで、おおよそ出現頻度の高い値とその件数からなる配列を返します。

# approx_top_k

<div id="approx_top_k">
  ## approx\_top\_k
</div>

導入バージョン: v1.1.0

指定されたカラム内で、おおよそ出現頻度が最も高い値とその出現回数の配列を返します。
返される配列は、値そのものではなく、値のおおよその出現頻度の高い順にソートされます。

この関数は、結果を保証するものではありません。
状況によってはエラーが発生し、最頻値ではない頻出値が返されることがあります。

**構文**

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

**別名**: `approx_top_count`

**パラメータ**

* `N` — 返す要素数。デフォルト値: `10`。`N` の最大値は `65536`。[`UInt64`](/ja/reference/data-types/int-uint)
* `reserved` — オプション。値の格納用に予約するセル数を指定します。`uniq(column) > reserved` の場合、結果は近似になります。デフォルト値: `N * 3`。[`UInt64`](/ja/reference/data-types/int-uint)

**引数**

* `column` — 最も頻出する値を求める対象のカラム名。[`String`](/ja/reference/data-types/string)

**戻り値**

近似的に最も頻出する値とその出現回数を、概算の出現頻度の高い順に並べた配列を返します。[`Array`](/ja/reference/data-types/array)

**例**

**使用例**

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

```response title=Response theme={null}
┌─approx_top_k(2)(k)────┐
│ [('y',3,0),('x',1,0)] │
└───────────────────────┘
```

**関連項目**

* [topK](/ja/reference/functions/aggregate-functions/topK)
* [topKWeighted](/ja/reference/functions/aggregate-functions/topKWeighted)
* [approx\_top\_sum](/ja/reference/functions/aggregate-functions/approxtopsum)
