美文网首页
2020-04-09-(03)

2020-04-09-(03)

作者: DUYAN_bc77 | 来源:发表于2020-04-10 09:53 被阅读0次

查找重复数据

编写一个 SQL 查询,查找 Person 表中所有重复的电子邮箱。

Screen Shot 2020-04-09 at 10.08.49 PM.png

Solution1

select Email
from Person
group by Email
having count(Email) > 1;

Solution2
自连接:不建议使用

Select distinct a.Email
From Person a join Person b
on a.Email=b.Email and a.Id<>b.Id

相关文章

网友评论

      本文标题:2020-04-09-(03)

      本文链接:https://www.haomeiwen.com/subject/qrqkmhtx.html