182 查找重复的电子邮箱
关键词:重复
解法一:group by + having
231 ms
select Email
from Person
group by Email
having count(Email) > 1;
解法二:distinct + 自连接
237 ms
select distinct p1.Email
from Person as p1, Person as p2
where p1.Email = p2.Email and p1.Id != p2.Id;
239 ms
select distinct p1.Email
from Person as p1
inner join Person as p2
on p1.Email = p2.Email and p1.Id < p2.Id;
解法三:子查询 + where
232 ms
select Email
from (
select Email, count(Email) as num
from Person
group by Email
) as statistic
where num > 1;

浙公网安备 33010602011771号