面试题:查询重复的Email地址

难度:容易

写一段SQL,在表Person中查找所有重复的Email地址。

+----+---------+
| Id | Email   |
+----+---------+
| 1  | a@b.com |
| 2  | c@d.com |
| 3  | a@b.com |
+----+---------+

例如:如上面数据,将返回:

+---------+
| Email   |
+---------+
| a@b.com |
+---------+

注意:所有的Email地址都是小写。

 

答案:

SELECT Email FROM Person GROUP BY Email HAVING count(Email)>1;

posted @ 2015-08-24 21:07  -小城-  阅读(199)  评论(0编辑  收藏  举报