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

# uniqCombined

<h2 id="uniqCombined">
  uniqCombined
</h2>

Introduced in: v1.1.0

Calculates the approximate number of different argument values.
It provides the result deterministically (it does not depend on the query processing order).

<Note>
  Since it uses a 32-bit hash for non-String types, the result will have very high error for cardinalities significantly larger than `UINT_MAX` (the error will raise quickly after a few tens of billions of distinct values).
  In the case cardinalities are larger than `UINT_MAX`, you should use [`uniqCombined64`](/reference/functions/aggregate-functions/uniqCombined64) instead.
</Note>

Compared to the uniq function, the uniqCombined function:

* Consumes several times less memory
* Calculates with several times higher accuracy
* Usually has slightly lower performance. In some scenarios, uniqCombined can perform better than uniq, for example, with distributed queries that transmit a large number of aggregation states over the network

<Accordion title="Implementation details">
  This function calculates a hash (64-bit hash for String and 32-bit otherwise) for all parameters in the aggregate, then uses it in calculations.
  It uses a combination of three algorithms: array, hash table, and HyperLogLog with an error correction table:

  * For a small number of distinct elements, an array is used
  * When the set size is larger, a hash table is used
  * For a larger number of elements, HyperLogLog is used, which will occupy a fixed amount of memory
</Accordion>

**Syntax**

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

**Parameters**

* `HLL_precision` — Optional. The base-2 logarithm of the number of cells in HyperLogLog. The default value is 17, which is effectively 96 KiB of space (2^17 cells, 6 bits each). Range: \[12, 20]. [`UInt8`](/reference/data-types/int-uint)

**Arguments**

* `x` — 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}
SELECT uniqCombined(number) FROM numbers(1e6);
```

```response title=Response theme={null}
┌─uniqCombined(number)─┐
│              1001148 │
└──────────────────────┘
```

**With custom precision**

```sql title=Query theme={null}
SELECT uniqCombined(15)(number) FROM numbers(1e5);
```

```response title=Response theme={null}
┌─uniqCombined(15)(number)─┐
│                   100768 │
└──────────────────────────┘
```

**See Also**

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