乐趣区

关于sql:Leetcode数据库刷题

1. 查找反复的电子邮箱

本人想法(谬误)

SELECT a.Email
FROM Person a,Person b
WHERE a.Email = b.Email

后果:表内全副呈现
解决思路:计算每封邮件的存在次数

SELECT Email
FROM Person 
GROUP BY Email
HAVING COUNT(Email)>1

解二:创立长期表

SELECT Email
FROM(SELECT Email,COUNT(Email) as num
 FROM Person
 GROUP BY Email
) tmp_table~~~~
WHERE num>1
退出移动版