Leetcode 196 Delete Duplicate Emails
2015-06-26 10:35
375 查看
Write a SQL query to delete all duplicate email entries in a table named
For example, after running your query, the above
Person, keeping only unique emails based on its smallest Id.
+----+------------------+ | Id | Email | +----+------------------+ | 1 | john@example.com | | 2 | bob@example.com | | 3 | john@example.com | +----+------------------+ Id is the primary key column for this table.
For example, after running your query, the above
Persontable should have the following rows:
+----+------------------+ | Id | Email | +----+------------------+ | 1 | john@example.com | | 2 | bob@example.com | +----+------------------+
delete a from Person a, Person b where a.Email = b.Email and a.Id > b.Id
相关文章推荐
- 关于VS2010中出现unresolved external symbol _main错误,提供一个可解决的方案
- Codeforces Beta Round #29 (Div. 2, Codeforces format) C. Mail Stamps 离散化拓扑排序
- ERROR 1872 (HY000): Slave failed to initialize relay log info structure from the repository
- drawpaint的类方法
- 延迟加载导致的问题的解决 failed to lazily initialize a collection of role
- leetcode由易入难——【3】Climbing Stairs
- 为什么要用DLL文件 http://blog.csdn.net/zhongjling/article/details/8089008
- @property (nonatomic,retain)中…
- rails 环境搭建
- Rails Marshal 简单例子讲解
- #leetcode#Contains Duplicates III
- wait和sleep区别
- TurboMail为企业海外扩张提供分布式邮件系统
- RAID0 RAID1 RAID2 RAID3 RAID4 RAID5 RAID6 RAID7 RAID10
- UVA 11853 - Paintball 战场(dfs)
- 7.Error提示: main cannot be resolved or is not a field
- 服务器TIME_WAIT和CLOSE_WAIT区别及解决方案
- S01E22 Growing Pains
- AIDL:远程调用服务里的方法失败,提示取得的IBinder对象NullPointerException
- leetcode[172]:Factorial Trailing Zeroes