Select statement wrong answer

  • 0

    Wrong answer solution needs an explanation.

    select * from Person p1 where not exists (select * from Person p2 where p1.Id>p2.Id and  p1.Email=p2.Email)

    test sample and solution as follow:
    Submission Result:

    Wrong AnswerMore Details

    Input: {"headers": {"Person": ["Id", "Email"]}, "rows": {"Person": [[1, ""], [2, ""]]}}

    Output: {"headers": ["Id", "Email"], "values": [[1, ""], [2, ""]]}

    Expected: {"headers": ["Id", "Email"], "values": [[1, ""]]}

  • 0

    In your SQL code you are not deleting any rows from the original table;
    the question asks to delete the rows with duplicated email, and keeping
    the row with the smallest Id.
    In your code you are trying to select these rows, but the original table
    remain the same in this way.

  • 0

    Oh you're right. That's part of the case. Another question is, i got an wrong answer, but the syntax and logic should not be wrong.

Log in to reply

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