- 类别:
DUPLICATE_COUNT(系统数据指标函数)¶
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.
语法¶
SNOWFLAKE.CORE.DUPLICATE_COUNT(<query>)
实参¶
querySpecifies a SQL query that projects one or more columns.
允许的数据类型¶
The columns projected by the query must have one of the following data types:
DATE
FLOAT
NUMBER
TIMESTAMP_LTZ
TIMESTAMP_NTZ
TIMESTAMP_TZ
VARCHAR
返回¶
该函数返回一个数据类型为 NUMBER 的标量值。
示例¶
确定 SSN 列中重复的 US 社会保险号的数量:
SELECT SNOWFLAKE.CORE.DUPLICATE_COUNT(
SELECT
ssn
FROM hr.tables.empl_info
);
Associate the DMF with a table to determine the number of duplicates based on the combination of the first_name and last_name
columns:
ALTER TABLE t
ADD DATA METRIC FUNCTION SNOWFLAKE.CORE.DUPLICATE_COUNT
ON (first_name, last_name);