- Categories:
DUPLICATE_ COUNT (system data metric function)¶
Returns the count of column values that have duplicates, including NULL values. If you specify more than one column argument, returns the number of rows where the combination of the specified columns is duplicated.
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.
Syntax¶
Arguments¶
querySpecifies 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.
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
Returns¶
The function returns a scalar value with a NUMBER data type.
Usage notes¶
When you call the function directly, the query must project exactly one column. If the query projects
more than one column, the call fails with an error similar to the following:
To count duplicates for a combination of columns, associate the function with a table as shown in the Examples.
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: