首页 > 其他 > 详细

182. 查找重复的电子邮箱 + group by + having

时间:2021-03-02 19:58:37      阅读:17      评论:0      收藏:0      [点我收藏+]

182. 查找重复的电子邮箱

LeetCode_MySql_182

题目描述

技术分享图片

方法一:使用笛卡尔积

# Write your MySQL query statement below
select distinct t1.Email
from 
     Person t1,
     Person t2
where 
     t1.Id != t2.Id
     and t1.Email = t2.Email;

方法二:使用group by 和临时表

select Email
from
(
    select Email, count(Email) as num
    from Person
    group by Email
) as temp
where num > 1;

方法三:使用group by + having

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

182. 查找重复的电子邮箱 + group by + having

原文:https://www.cnblogs.com/GarrettWale/p/14470543.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!