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

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

示例:

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

来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/duplicate-emails
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。`

解题:

select Email 
from person 
group by Email
having count(email)>1

tips:
这里要分清 where ,group by,having 的顺序
where 作用于基本表或者视图,
group by 对表中的数据分组
having 就是分组后按照一定条件筛选

猜你喜欢

转载自blog.csdn.net/qq_43964318/article/details/108832629