SQL 重复行

SQL Duplicate rows

我正在为我的 CRM 编写 SQL 查询。

我的 table 如下所示:

EML SubKey
----------
 A    A
 A    1
 B    B
 C    2

我想 select 具有非数字子键的唯一电子邮件和重复电子邮件。

请帮助我:)

结果应该是这样的

A A
B B
C 2


SELECT DISTINCT
EML
FROM _ListSubscribers

SELECT SubscriberKey 
FROM _ListSubscribers
WHERE ISNUMERIC(SubscriberKey) = 0

更新后的查询应该会为您提供所需的结果:

SELECT 
  EML
  , SubscriberKey 
FROM _ListSubscribers 
WHERE EML IN (
    SELECT EML 
    FROM _ListSubscribers 
    GROUP BY EML 
    HAVING COUNT(*) = 1
) 

UNION 

SELECT 
  EML
  , SubscriberKey 
FROM _ListSubscribers 
WHERE EML IN (
    SELECT EML 
    FROM _ListSubscribers 
    GROUP BY EML 
    HAVING COUNT(* ) > 1
) AND ISNUMERIC(SubscriberKey) = 0