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

> Calculates the approximate number of different argument values. It is the same as uniqCombined, but uses a 64-bit hash for all data types rather than just for the String data type.

# uniqCombined64

<h2 id="uniqCombined64">
  uniqCombined64
</h2>

Introduced in: v20.1.0

Calculates the approximate number of different argument values.
It is the same as [`uniqCombined`](/reference/functions/aggregate-functions/uniqCombined), but uses a 64-bit hash for all data types rather than just for the String data type.

This function provides the result deterministically (it does not depend on the query processing order).

<Note>
  Since it uses 64-bit hash for all types, the result does not suffer from very high error for cardinalities significantly larger than `UINT_MAX` like [`uniqCombined`](/reference/functions/aggregate-functions/uniqCombined) does, which uses a 32-bit hash for non-String types.
</Note>

Compared to the [uniq](/reference/functions/aggregate-functions/uniq) function, the uniqCombined64 function:

* Consumes several times less memory
* Calculates with several times higher accuracy

<Accordion title="Implementation details">
  This function calculates a 64-bit hash for all data types for all parameters in the aggregate, then uses it in calculations.
  It uses a combination of three algorithms: array, hash table, and [HyperLogLog](https://en.wikipedia.org/wiki/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}
uniqCombined64(HLL_precision)(x[, ...])
uniqCombined64(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**

**Large dataset example**

```sql title=Query theme={null}
SELECT uniqCombined64(number) FROM numbers(1e10);
```

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

**Comparison with uniqCombined**

```sql title=Query theme={null}
-- uniqCombined64 with large dataset
SELECT uniqCombined64(number) FROM numbers(1e10);

-- uniqCombined with same dataset shows poor approximation
SELECT uniqCombined(number) FROM numbers(1e10);
```

```response title=Response theme={null}
┌─uniqCombined64(number)─┐
│             9998568925 │ -- 10.00 billion
└────────────────────────┘
┌─uniqCombined(number)─┐
│           5545308725 │ -- 5.55 billion
└──────────────────────┘
```

**See Also**

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