Wednesday, September 27, 2017

196. Delete Duplicate Emails

https://leetcode.com/problems/delete-duplicate-emails/description/
delete p1
from Person p1, Person p2
where p1.Email = p2.Email
and p1.Id > p2.Id

Solution 2.
delete from Person where id not in( select t.id from ( select min(id) as id from Person group by email ) t )

No comments:

Post a Comment