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

> Calcula o número aproximado de valores de argumento distintos usando o Theta Sketch Framework.

# uniqTheta

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

Introduzido na versão: v21.6.0

Calcula o número aproximado de diferentes valores de argumento usando o [Theta Sketch Framework](https://datasketches.apache.org/docs/Theta/ThetaSketches.html#theta-sketch-framework).

<Accordion title="Detalhes de implementação">
  Esta função calcula um hash para todos os parâmetros da agregação e depois o usa nos cálculos.
  Ela usa o algoritmo [KMV](https://datasketches.apache.org/docs/Theta/InverseEstimate.html) para aproximar o número de diferentes valores de argumento.

  São usados 4096(2^12) sketches de 64 bits.
  O tamanho do estado é de cerca de 41 KB.

  O erro relativo é de 3,125% (95% de confiança); consulte a [tabela de erro relativo](https://datasketches.apache.org/docs/Theta/ThetaErrorTable.html) para mais detalhes.
</Accordion>

**Sintaxe**

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

**Argumentos**

* `x` — A função aceita um número variável de parâmetros. [`Tuple(T)`](/pt-BR/reference/data-types/tuple) ou [`Array(T)`](/pt-BR/reference/data-types/array) ou [`Date`](/pt-BR/reference/data-types/date) ou [`DateTime`](/pt-BR/reference/data-types/datetime) ou [`String`](/pt-BR/reference/data-types/string) ou [`(U)Int*`](/pt-BR/reference/data-types/int-uint) ou [`Float*`](/pt-BR/reference/data-types/float) ou [`Decimal`](/pt-BR/reference/data-types/decimal)

**Valor retornado**

Retorna um número do tipo UInt64 que representa a quantidade aproximada de valores de argumento distintos. [`UInt64`](/pt-BR/reference/data-types/int-uint)

**Exemplos**

**Uso básico**

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

**Veja também**

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