码疯窝

LeetCode 每日一题 — Duplicate Emails

2015/01/19 10:38:28    分类: 日志连载    0人评论 次浏览

Write a SQL query to find all duplicate emails in a table named Person.

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

For example, your query should return the following for the above table:

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

Note: All emails are in lowercase.

分析: 此题目依旧是基础得不能再基础了, 考察having语句. 真心没明白题目里加个note 说emails都是小写有任何影响. =.=

SELECT Email FROM Person
GROUP BY Email
HAVING COUNT(1) > 1
继续查看有关 日志连载的文章

0个访客评论