LeetCode 数据库面试题 – 查找重复的电子邮箱

本页内容

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

示例:

IdEmail
1[email protected]
2[email protected]
3[email protected]

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

Email
[email protected]

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

答案

1SELECT 
2    Email
3FROM (
4    SELECT 
5        Email, count(*) as amount
6    FROM Person
7    GROUP BY Email
8) t
9WHERE amount > 1

原题

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/duplicate-emails