选择重复项并根据非重复列进行选择

Choose the duplicates and pick based on non duplicate column

我需要在下面写一个查询 table 以仅当超过 1 个成员共享相同的电子邮件和姓名时才获取记录。在下面的例子中,我需要结果集为

100          a@a.com       nameA  
300           a@a.com      nameA

Table

Member  email               name  
100           a@a.com       nameA  
100           a@a.com       nameA  
300           a@a.com       nameA  
200           b@b.com       nameB

我怀疑您有错字,您的预期结果是 100 而不是 200。如果是这样,那么有一种方法:

with your_table(Member, email , name ) as (
    select 100,'a@a.com','nameA' union all
    select 100,'a@a.com','nameA' union all
    select 300,'a@a.com','nameA' union all
    select 200,'b@b.com','nameB'  
)

-- below is actual query:

select distinct your_table.* 
from your_table
inner join (
    select  email , name from your_table
    group by email ,  name
    having count(distinct Member) > 1
) t
on your_table.email = t.email and your_table.name = t.name