题目:
思路:
使用group by 就很快获得结果,但是在leetcode上不能通过
代码:
SELECT min(Id) as Id, Email
FROM Person
GROUP By Email
ORDER By Id
结果如下:
如果要用DELETE 来写,也可以的。
先把DELETE的语法写出来:
DELETE FROM 表名称 WHERE 列名称 = 值
代码:
DELETE
p2
FROM Person as p1, Person as p2
WHERE p1.Email = p2.Email AND p1.Id < p2.Id
结果如下:
如果觉得还有其他好的方法,就留言吧~
觉得不错,就点赞或者关注~~
谢谢~ ~