182. Duplicate Emails
来源:互联网 发布:js分页思路 编辑:程序博客网 时间:2024/06/06 09:27
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语句和where语句上:
[1]having与where类似,可以筛选数据,where后的表达式怎么写,having后就怎么写
[2]能用where的地方 也能用having ,用having的地方 不一定能用where(因为having字句可以让我们筛选成组后的各种数据,where字句在聚合前先筛选记录,也就是说作用在group by和having字句前。而 having子句在聚合后对组记录进行筛选。)
[2]能用where的地方 也能用having ,用having的地方 不一定能用where(因为having字句可以让我们筛选成组后的各种数据,where字句在聚合前先筛选记录,也就是说作用在group by和having字句前。而 having子句在聚合后对组记录进行筛选。)
where针对表中的列发挥作用,查询数据
having是对查询结果中得到的列发挥作用,筛选数据(也就是说从查询出的结果集再次进行筛选)
having是对查询结果中得到的列发挥作用,筛选数据(也就是说从查询出的结果集再次进行筛选)
select Email from Person group by Email having count(Email)>1;
阅读全文
0 0
- leetcode 182. Duplicate Emails
- 182. Duplicate Emails
- 182. Duplicate Emails
- leetcode.182. Duplicate Emails
- leetcode 182. Duplicate Emails
- leetcode 182. Duplicate Emails
- 182. Duplicate Emails
- Leetcode 182. Duplicate Emails
- 182. Duplicate Emails (E)
- 182. Duplicate Emails#2
- 182. Duplicate Emails
- 182. Duplicate Emails
- 182. Duplicate Emails
- 182. Duplicate Emails
- 【LeetCode】182. Duplicate Emails
- 182.Duplicate Emails
- 【leetcode Database】182. Duplicate Emails
- [leetcode][SQL]182. Duplicate Emails
- mysql常用函数汇总(转载)
- 【Java概念】抽象类(10)
- sails-mongo 使用 groupBy 进行分组遇到的坑
- Tomcat 6中配置BoneCP数据源
- 使用Tomcat-redis-session-manager来实现Tomcat集群部署中的Session共享
- 182. Duplicate Emails
- 用Struts输出Hello
- 连岗位需求都不知道,你凭什么能胜任这份工作?
- Windows程序设计-模态对话框和非模态对话框
- 19个必须知道的Visual Studio快捷键
- Java中ArrayList和LinkedList区别
- 第二周 程序的多文件组织
- 一位资深程序员大牛给予Java初学者的学习路线建议
- 百度云推送与APNS推送结合项目经验心得