IT编程 > 数据库 > Mysql

LeetCode——Duplicate Emails(使用group by以及having解决分组统计结果)

192人参与2019-10-09

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.

题意:查找表中重复的email.
此题是很典型的对分组结果进行统计筛选例题,因此可以利用group by进行分组,然后使用having统计.

# write your mysql query statement below
select email from person group by email having count(email) > 1;

此处,对wheregroup by进行比较(引用自:):

您对本文有任何疑问!!点此进行留言回复

推荐阅读

猜你喜欢

LeetCode——Duplicate Emails(使用group by以及having解决分组统计结果)

10-09

MySQL(学生表、教师表、课程表、成绩表)多表查询

10-09

LeetCode——Employees Earning More Than Their Managers

10-09

LeetCode——Consecutive Numbers

10-09

LeetCode——Rank Scores

10-09

24H玩转 Grafana 被工程师称相当专业,如何做到?

10-09

拓展阅读

大家都在看

winx64版本下mysql8.0.11安装时MySQL服务正在启动到MySQL服务无法启动的问题分析

11-01

mysql时间与字符串之间相互转换

01-21

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause 的问题 MySQL

09-03

在CentOS7上安装MySQL5.7-YUM源方式

04-21

MySQL从删库到跑路(四)——MySQL数据库创建实例

10-15

mysql 8.0.22 安装配置图文教程

11-12

mysql-utilities 出现 No module named utilities

08-18

mysql-community-common(x86-64))=5.7.9isneededbymysql-community-libs-4报错问题解决

11-05

热门评论