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