【MySQL数据库查询语句】leetcode Duplicate Emails

来源:转载

题目

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

+—-+———+
| Id | Email |
+—-+———+
| 1 | [email protected] |
| 2 | [email protected] |
| 3 | [email protected] |
+—-+———+
For example, your query should return the following for the above table:

+———+
| Email |
+———+
| [email protected] |
+———+
Note: All emails are in lowercase.
题目来源:https://leetcode.com/problems/duplicate-emails/

代码

有哪些邮箱重复?把邮箱显示出来。

# Write your MySQL query statement belowselect Email from Person group by Email having count(Id) > 1;

注:MySQL中having关键字是在数据分组之后进行过滤选择分组,而where是在分组之前用来选择记录。where排除的记录不再包括在分组中。


分享给朋友:
您可能感兴趣的文章:
随机阅读: