APPROX_COUNT_DISTINCT

Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API

Computes an approximation of the count of distinct values with a specified expected relative error.

  • <expression>: An expression of any type to count distinct values for.
  • <error>: A double precision value specifying the expected relative error. Must be in the range (0.002, 1]. Defaults to 0.023 (2.3% expected relative error).

Returns a bigint representing the approximate count of distinct values.

  • Faster than exact count(distinct expression) for large datasets.
  • The error parameter controls the trade-off between accuracy and performance.
  • Lower error values provide more accurate results but may require more computation.

Get an approximate count of distinct values.

Specify a custom error rate for higher accuracy.

Returns an approximate count with 1% expected relative error.