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


  • 16
    X

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

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


  • 4
    J

    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.


  • 0
    C

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


  • 0
    X

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


  • 0
    P

    @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.