leetcode182-Duplicate Emails(找出出现重复的数据)
2016-04-08 11:31
501 查看
问题描述:
Write a SQL query to find all duplicate emails in a table named Person.
For example, your query should return the following for the above table:
问题求解:
1、distinct
2、group by & having
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 | +---------+
问题求解:
1、distinct
select distinct p1.email from Person p1, Person p2 where p1.email = p2.email and p1.Id != p2.Id
2、group by & having
select email from Person group by email having count(*)>1
相关文章推荐
- Fibonacci Again
- Linxu tailf --跟踪日志文件
- Linux tail --输出文件尾部/动态监控文件尾部
- atomic nonatomic assign retain copy strong weak 介绍
- adb连接安卓设备失败failed to start daemon
- thread的wait\notify实现线程通信
- 【原创】k8s源码分析-----kubelet(3)ContainerGC
- [poj 1691] Painting A Board dfs+拓扑排序
- synchronized ,notify(),wait(),Thread.sleep();
- HDOJ 1302(UVa 573) The Snail(蜗牛爬井)
- HDOJ 1302(UVa 573) The Snail(蜗牛爬井)
- 【UVa】11456 - Trainsorting
- 朴素贝叶斯(Naive-Bayes)介绍
- error: linker command failed with exit code 1 (use -v to see invocation)
- Team:Syclover Author:L3m0n Email:iamstudy@126.com
- IBM服务器 RAID5 阵列卡配置教程
- 算法之动态规划-矩阵链相乘(matrix-chain multiplication)
- HP服务器RAID 0阵列配置教程
- POJ-3411 Paid Roads
- 11. Container With Most Water