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

> Theta Sketch Framework を使用して、異なる引数の値のおおよその数を計算します。

# uniqTheta

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

導入バージョン: v21.6.0

[Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketches.html#theta-sketch-framework) を使用して、異なる引数の値のおおよその個数を計算します。

<Accordion title="実装の詳細">
  この関数は、集約内のすべてのパラメータに対してハッシュを計算し、それを計算に使用します。
  [KMV](https://datasketches.apache.org/docs/Theta/InverseEstimate.html) アルゴリズムを使用して、異なる引数の値のおおよその個数を求めます。

  4096 (2^12) 個の 64-bit スケッチが使用されます。
  state のサイズは約 41 KB です。

  相対誤差は 3.125% (信頼度 95%) です。詳細については、[relative error table](https://datasketches.apache.org/docs/Theta/ThetaErrorTable.html) を参照してください。
</Accordion>

**構文**

```sql theme={null}
uniqTheta(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_theta
(
    id UInt32,
    category String
)
ENGINE = Memory;

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

SELECT uniqTheta(category) as theta_unique_categories
FROM example_theta;
```

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

**関連項目**

* [uniq](/ja/reference/functions/aggregate-functions/uniq)
* [uniqCombined](/ja/reference/functions/aggregate-functions/uniqCombined)
* [uniqCombined64](/ja/reference/functions/aggregate-functions/uniqCombined64)
* [uniqHLL12](/ja/reference/functions/aggregate-functions/uniqHLL12)
* [uniqExact](/ja/reference/functions/aggregate-functions/uniqExact)
