Returns an approximate distinct value number, similar to
COUNT(DISTINCT col). NDV can return results faster than using
the combination of COUNT and DISTINCT while using a constant amount of memory, resulting in less memory usage for
columns with high cardinality.
SELECT NDV(column_name) -- 163
precision = scale +8. Enter an integer in the range from 1 to 10.
SELECT NDV(column_name, 1) -- 162
The NDV function is used internally by the
COMPUTE STATS statement for computing the number of distinct values in a column. This function might not reflect the precise number of different values in the column, especially if the cardinality is very low or very high. This function accepts the DISTINCT and ALL keywords:
NDV([DISTINCT | ALL] expression).
Learn more about window functions.