I can't believe I get it wrong! What's wrong with my code?

  • 17

    select email,min(id) from Person group by email

    This is very simple sql right? How's possible it return duplicate emails?

  • 6

    The question is "Write a SQL query to delete all duplicate email entries in a table named Person", you should delete the mismatch data from Person.

  • 1

    min is aggregate and returns only one value. Selection of aggregate and multi-valued column will result in error.

  • 1

    because you do not delete the duplicated email, you just select it

  • 0

    @xiangyucao yes, quite odd that I encounter the same issue and seems there is a trick for leetcode to return result in JSON format. Tried this on other online and my own mysql, It's got returned normally.

Log in to reply

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