-
196. Delete Duplicate Emails mysqlLeetCode_Study_Plan/SQL 2022. 9. 26. 22:08
https://leetcode.com/problems/delete-duplicate-emails/?envType=study-plan&id=sql-i
delete from person where id not in ( select sub.min_id from ( select min(id) as min_id, email from person group by email) as sub);
서브쿼리부터 어려워서 답지를 봤다.. ㅠ
출처 : https://minni7.tistory.com/23
distinct를 쓰는 게 아닌 것 같아서 group by를 해야하고, group by를 한 컬럼은 반드시 select에 들어가야 하니 또 서브쿼리를 짜야하는 문제..
'LeetCode_Study_Plan > SQL' 카테고리의 다른 글
1484. Group Sold Products By The Date mysql (0) 2022.09.27 1667. Fix Names in a Table oracle (0) 2022.09.27 627. Swap Salary mysql (0) 2022.09.26 1873. Calculate Special Bonus mysql (0) 2022.09.26 183. Customers Who Never Order mysql (1) 2022.09.25