196. Delete Duplicate Emails

原创 2016年08月29日 22:46:41

Write a SQL query to delete all duplicate email entriesin a table named 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 thistable.

For example,after running your query, the above Person tableshould have the following rows:

+----+------------------+

| Id | Email            |

+----+------------------+

| 1 | john@example.com |

| 2 | bob@example.com  |

+----+------------------+


DELETE a
FROM Person a, Person b
WHERE a.Id>b.Id AND a.Email=b.Email;




版权声明:本文为博主原创文章,未经博主允许不得转载。

leetcode 196. Delete Duplicate Emails

196. Delete Duplicate Emails   Question Editorial Solution  My Submissions To...
  • yuxin6866
  • yuxin6866
  • 2016年08月08日 14:50
  • 899

leetcode 196. Delete Duplicate Emails delete

题意:删除Email重复的行,保留Id最小的行,也就使每个Email只保留Id最小那个 思路:用删除语句进行删除 题目链接:https://leetcode.com/problem...
  • wyt734933289
  • wyt734933289
  • 2016年05月11日 22:27
  • 488

leetcode196-Delete Duplicate Emails(删除重复并且id较大的数据)

问题描述:Write a SQL query to delete all duplicate email entries in a table named Person, keeping only u...
  • will130
  • will130
  • 2016年04月09日 16:59
  • 559

196. Delete Duplicate Emails

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only uniq...
  • qq_27991659
  • qq_27991659
  • 2016年05月23日 11:12
  • 134

[LeetCode]--196. Delete Duplicate Emails

[LeetCode]--196. Delete Duplicate Emails SQL
  • beijingbuaaer
  • beijingbuaaer
  • 2016年08月11日 10:09
  • 98

【LeetCode】196. Delete Duplicate Emails

题目要求:Write a SQL query to delete all duplicate email entries in a table named Person, keeping only...
  • u013628902
  • u013628902
  • 2017年09月28日 10:07
  • 45

leetcode 196. Delete Duplicate Emails

题目:196. Delete Duplicate Emails 1。建表create table Person( Id int not null auto_increment, Em...
  • wangwenhao00
  • wangwenhao00
  • 2017年06月08日 15:49
  • 226

Leetcode 196. Delete Duplicate Emails

196. Delete Duplicate Emails Total Accepted: 16136 Total Submissions: 85584 Difficulty: Easy Wri...
  • fantasiasango
  • fantasiasango
  • 2016年09月01日 03:05
  • 402

[LeetCode] 196. Delete Duplicate Emails

Write a SQL query to delete all duplicate email entries in a table named Person, keeping only uniqu...
  • u012525459
  • u012525459
  • 2016年04月09日 16:17
  • 135

LeetCode 196. Delete Duplicate Emails

Delete Duplicate Emails My Submissions QuestionEditorial Solution Total Accepted: 14121 Total Submi...
  • lcxlxm
  • lcxlxm
  • 2016年06月26日 22:02
  • 130
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:196. Delete Duplicate Emails
举报原因:
原因补充:

(最多只允许输入30个字)