DUPLICATE_COUNT

functionsupportedGovernance (policies, tags, data quality)Enterprise+

docs.snowflake.com ↗

Data metric functions

Returns the number of distinct values that occur more than once in a column, counting NULL as a value. If you specify more than one column argument, returns the number of distinct combinations of the specified columns that occur more than once. If you want to specify more than one column argument, you can’t call the function directly. For an example of associating the function with a table so you can specify multiple column arguments, see Examples. Data Quality Monitoring requires Enterprise Edition. To inquire about upgrading, please contact Snowflake Support.

Syntax

SNOWFLAKE.CORE.DUPLICATE_COUNT(<query>)

Parameters

NameRequiredDescription
queryrequiredSpecifies a SQL query that projects exactly one column when you call the function directly. To measure duplicates across multiple columns, associate the function with a table by using ALTER TABLE ... ADD DATA METRIC FUNCTION ... ON (col1, col2). For an example, see Examples.

Returns

The function returns a scalar value with a NUMBER data type.

Usage notes

Allowed data types

The columns projected by the query must have one of the following data types: - DATE - FLOAT - NUMBER - TIMESTAMP_LTZ - TIMESTAMP_NTZ - TIMESTAMP_TZ - VARCHAR

Example

Determine the number of duplicate US Social Security numbers in the SSN column: Associate the DMF with a table to determine the number of duplicates based on the combination of the first_name and last_name columns: