美文网首页
【LeetCode】182. 查找重复的电子邮箱

【LeetCode】182. 查找重复的电子邮箱

作者: Shenjiming | 来源:发表于2018-08-24 17:39 被阅读23次

LeetCode数据库题目

题目

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

+----+---------+
| Id | Email   |
+----+---------+
| 1  | a@b.com |
| 2  | c@d.com |
| 3  | a@b.com |
+----+---------+

根据以上输入,你的查询应返回以下结果:

+---------+
| Email   |
+---------+
| a@b.com |
+---------+

思路

  1. 查询目标:Email
  2. 查询范围:Person表
  3. 查询条件:电子邮件是重复的

解答

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

相关文章

网友评论

      本文标题:【LeetCode】182. 查找重复的电子邮箱

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