Skip to content

Latest commit

 

History

History
51 lines (33 loc) · 1.1 KB

182-duplicate-emails.md

File metadata and controls

51 lines (33 loc) · 1.1 KB

182. Duplicate Emails - 查找重复的电子邮箱

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

示例:

+----+---------+
| Id | Email   |
+----+---------+
| 1  | [email protected] |
| 2  | [email protected] |
| 3  | [email protected] |
+----+---------+

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

+---------+
| Email   |
+---------+
| [email protected] |
+---------+

说明:所有电子邮箱都是小写字母。


题目标签:

题目链接:LeetCode / LeetCode中国

题解

在用子查询时:

Every derived table must have its own alias

原因:要给子表取个别名。

Language Runtime Memory
mysql 401 ms N/A
SELECT Email FROM (SELECT Email, COUNT(Email) c FROM Person GROUP BY Email) t WHERE t.c>1;