找到重复的email链接
Table: Person
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| Id | int |
| Email | varchar |
+-------------+---------+
Input:
Person table:
+----+---------+
| Id | Email |
+----+---------+
| 1 | a@b.com |
| 2 | c@d.com |
| 3 | a@b.com |
+----+---------+
Output:
+---------+
| Email |
+---------+
| a@b.com |
+---------+
使用 GROUPBY 和临时表
- Runtime: 340 ms, faster than 46.56%
- Memory Usage: 0B, less than 100.00%
SELECT Email FROM
(
SELECT Email, COUNT(Email) AS num
FROM Person
GROUP BY Email
) AS statistic
WHERE num > 1
使用GROUPBY 和 HAVING
- Runtime: 342 ms, faster than 45.46%
- Memory Usage: 0B, less than 100.00%
SELECT Email
FROM Person
GROUP BY Email
HAVING COUNT(Email) > 1
网友评论