ClickHouse/docs/en/sql-reference/aggregate-functions/reference/uniq.md
Peignon Melvyn 38a40f27fb
Remove a code
I removed a sentence that was in a code section, it didn't feel that it was intended initially.
2021-12-27 18:12:19 +01:00

1.5 KiB

toc_priority
190

uniq

Calculates the approximate number of different values of the argument.

uniq(x[, ...])

Arguments

The function takes a variable number of parameters. Parameters can be Tuple, Array, Date, DateTime, String, or numeric types.

Returned value

Implementation details

Function:

  • Calculates a hash for all parameters in the aggregate, then uses it in calculations.

  • Uses an adaptive sampling algorithm. For the calculation state, the function uses a sample of element hash values up to 65536. This algorithm is very accurate and very efficient on the CPU. When the query contains several of these functions, using uniq is almost as fast as using other aggregate functions.

  • Provides the result deterministically (it does not depend on the query processing order).

We recommend using this function in almost all scenarios.

See Also