> ## 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.

> HyperLogLog アルゴリズムを使用して、異なる引数の値のおおよその個数を計算します。

# uniqHLL12

<div id="uniqHLL12">
  ## uniqHLL12
</div>

導入バージョン: v1.1.0

[HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) アルゴリズムを使用して、引数の異なる値のおおよその個数を計算します。

<Warning>
  この関数の使用は推奨されません。ほとんどの場合は、[uniq](/ja/reference/functions/aggregate-functions/uniq) または [uniqCombined](/ja/reference/functions/aggregate-functions/uniqCombined) 関数を使用してください。
</Warning>

<Accordion title="実装の詳細">
  この関数は、集約内のすべてのパラメータに対してハッシュを計算し、そのハッシュを使って計算を行います。
  HyperLogLog アルゴリズムを使用して、引数の異なる値のおおよその個数を求めます。

  2^12 個の 5 ビットセルを使用します。
  状態サイズは 2.5 KB をわずかに上回ります。
  小規模なデータセット (\<10K 要素) では、結果の精度はあまり高くなく、誤差は最大で約 10% です。
  ただし、高カーディナリティのデータセット (10K-100M) では比較的正確で、最大誤差は約 1.6% です。
  100M を超えると推定誤差は増加し、カーディナリティが極めて高いデータセット (1B+ 要素) では、この関数は非常に不正確な結果を返します。

  決定的な結果を返します (クエリ処理の順序に依存しません) 。
</Accordion>

**構文**

```sql theme={null}
uniqHLL12(x[, ...])
```

**引数**

* `x` — この関数は可変個の引数を受け取ります。[`Tuple(T)`](/ja/reference/data-types/tuple) または [`Array(T)`](/ja/reference/data-types/array) または [`Date`](/ja/reference/data-types/date) または [`DateTime`](/ja/reference/data-types/datetime) または [`String`](/ja/reference/data-types/string) または [`(U)Int*`](/ja/reference/data-types/int-uint) または [`Float*`](/ja/reference/data-types/float) または [`Decimal`](/ja/reference/data-types/decimal)

**戻り値**

異なる引数の値のおおよその個数を表す UInt64 型の数値を返します。[`UInt64`](/ja/reference/data-types/int-uint)

**例**

**基本的な使い方**

```sql title=Query theme={null}
CREATE TABLE example_hll
(
    id UInt32,
    category String
)
ENGINE = Memory;

INSERT INTO example_hll VALUES
(1, 'A'), (2, 'B'), (3, 'A'), (4, 'C'), (5, 'B'), (6, 'A');

SELECT uniqHLL12(category) AS hll_unique_categories
FROM example_hll;
```

```response title=Response theme={null}
┌─hll_unique_categories─┐
│                     3 │
└───────────────────────┘
```

**関連項目**

* [uniq](/ja/reference/functions/aggregate-functions/uniq)
* [uniqCombined](/ja/reference/functions/aggregate-functions/uniqCombined)
* [uniqExact](/ja/reference/functions/aggregate-functions/uniqExact)
* [uniqTheta](/ja/reference/functions/aggregate-functions/uniqthetasketch)
