196. Delete Duplicate Emails




196. Delete Duplicate Emails

리트코드


DELETE p1
FROM Person p1, Person p2
WHERE p1.Email = p2.Email
  AND p1.Id > p2.Id


DELETE FROM Person
 WHERE id NOT IN (
    SELECT id
      FROM (
        SELECT MIN(id) AS id, email
          FROM Person
      GROUP BY email) as sub
    )


1667. Fix Names in a Table

리트코드


SELECT user_id, CONCAT(upper(substring(name,1,1)), lower(substring(name, 2, length(name)-1))) as name
  FROM Users
ORDER BY user_id