No MySQL 8.0 existe a possibilidade de usar `RANK()` SELECT id, usuario_id, status FROM ( SELECT id, usuario_id, status, RANK() OVER (PARTITION BY usuario_id ORDER BY id DESC) AS intRow FROM Table1 WHERE status = 0 ) T WHERE intRow = 1 https://www.db-fiddle.com/f/7V6HBDsCmd4m9uPiz9cnWY/0 Para deletar os registros com ID repetido você poderia usar um código como esse: DELETE FROM Table1 WHERE id IN ( SELECT id FROM ( SELECT id, RANK() OVER (PARTITION BY usuario_id ORDER BY id DESC) AS intRow FROM Table1 WHERE status = 0 ) T WHERE intRow > 1 ); https://www.db-fiddle.com/f/7V6HBDsCmd4m9uPiz9cnWY/2