Why wouldn't it work?


  • 0
    S

    I not selecting the rows for whom there is no other rows with the same Email and larger Id.

    # Write your MySQL query statement below
    SELECT p1.Id, p1.Email
    FROM Person p1
    WHERE NOT EXISTS
    (SELECT 1 FROM Person p2 WHERE p1.Email = p2.Email AND p1.Id > p2.Id LIMIT 1)
    

    But it can not remove the duplicate in a very simple case and I do not understand why. Any idea?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.