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

> Calculates the approximate number of different argument values, using the Theta Sketch Framework.

# uniqTheta

<h2 id="uniqTheta">
  uniqTheta
</h2>

Introduced in: v21.6.0

Calculates the approximate number of different argument values, using the [Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketches.html#theta-sketch-framework).

<Accordion title="Implementation details">
  This function calculates a hash for all parameters in the aggregate, then uses it in calculations.
  It uses the [KMV](https://datasketches.apache.org/docs/Theta/InverseEstimate.html) algorithm to approximate the number of different argument values.

  4096(2^12) 64-bit sketch are used.
  The size of the state is about 41 KB.

  The relative error is 3.125% (95% confidence), see the [relative error table](https://datasketches.apache.org/docs/Theta/ThetaErrorTable.html) for detail.
</Accordion>

**Syntax**

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

**Arguments**

* `x` — The function takes a variable number of parameters. [`Tuple(T)`](/reference/data-types/tuple) or [`Array(T)`](/reference/data-types/array) or [`Date`](/reference/data-types/date) or [`DateTime`](/reference/data-types/datetime) or [`String`](/reference/data-types/string) or [`(U)Int*`](/reference/data-types/int-uint) or [`Float*`](/reference/data-types/float) or [`Decimal`](/reference/data-types/decimal)

**Returned value**

Returns a UInt64-type number representing the approximate number of different argument values. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Basic usage**

```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 │
└─────────────────────────┘
```

**See Also**

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