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

> Calculates the approximate number of different argument values, using the HyperLogLog algorithm.

# uniqHLL12

<h2 id="uniqHLL12">
  uniqHLL12
</h2>

Introduced in: v1.1.0

Calculates the approximate number of different argument values, using the [HyperLogLog](https://en.wikipedia.org/wiki/HyperLogLog) algorithm.

<Warning>
  We do not recommend using this function. In most cases, use the [uniq](/reference/functions/aggregate-functions/uniq) or [uniqCombined](/reference/functions/aggregate-functions/uniqCombined) function.
</Warning>

<Accordion title="Implementation details">
  This function calculates a hash for all parameters in the aggregate, then uses it in calculations.
  It uses the HyperLogLog algorithm to approximate the number of different argument values.

  2^12 5-bit cells are used.
  The size of the state is slightly more than 2.5 KB.
  The result is not very accurate (up to \~10% error) for small data sets (\<10K elements).
  However, the result is fairly accurate for high-cardinality data sets (10K-100M), with a maximum error of \~1.6%.
  Starting from 100M, the estimation error increases, and the function will return very inaccurate results for data sets with extremely high cardinality (1B+ elements).

  Provides a determinate result (it does not depend on the query processing order).
</Accordion>

**Syntax**

```sql theme={null}
uniqHLL12(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_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 │
└───────────────────────┘
```

**See Also**

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