【LeetCode】打卡--SQL182. 查找重复的电子邮箱

【LeetCode】打卡–SQL182. 查找重复的电子邮箱

题目

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

示例:

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

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

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

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

解答

/* Write your T-SQL query statement below */
Select 
    Distinct P1.Email
From 
    Person P1,Person P2
Where 
    P1.Email=P2.Email And P1.Id != P2.Id

我们下次再见,如果还有下次的话!!!
欢迎关注微信公众号:516数据工作室
516数据工作室

猜你喜欢

转载自blog.csdn.net/Asher117/article/details/88819861