嗨,我无法为这个问题获得正确的计数。我正在尝试计算具有不同名字和/或不同姓氏的重复电子邮件。(即 123@.com sam 123@.com 本我需要计算该重复电子邮件的数量)我正在使用 2 张桌子。email_address 在 mrtcustomer.customer_email 表中,名字和姓氏在 mrtcustomer.customer_master 表中
我的代码
SELECT COUNT(*)
FROM
(SELECT e.customer_master_id, email_address, customer_first_name, customer_last_name,
ROW_NUMBER() OVER (PARTITION BY EMAIL_ADDRESS ORDER BY CUSTOMER_FIRST_NAME) RN
FROM mrtcustomer.customer_email e
JOIN mrtcustomer.customer_master t ON e.customer_master_id = t.customer_master_id
WHERE t.customer_first_name IS NOT NULL
AND t.customer_last_name IS NOT NULL
AND customer_FIRST_NAME != 'Unknown'
AND customer_LAST_NAME != 'Unknown'
GROUP BY e.customer_master_id, email_address, customer_first_name, customer_last_name
ORDER BY 1 DESC)
WHERE RN > 1
我猜我的 WHERE 子句是错误的。