My solution using LIMIT OFFSET but has a problem


  • 0
    E

    I am trying to use LIMIT and OFFSET to return the duplicated IDs, but there is a problem:

    I can't figure out the number after the LIMIT. It should be the number of rows in that group minus 1, but how should I write it?

    delete
    from Person 
    where Id in (
        select b.Id
        from Person b
        group by b.Email
        having count(*) > 1
        order by b.Id asc
        limit count(*)-1 offset 1
    )
    

Log in to reply
 

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