Presuming id is unique and always incrementing, we need to first get the IDs for the highest unique usernames:
SELECT MAX(id)
FROM your_table_name
GROUP BY username
If you need to determine uniqueness based on additional columns (e.g. username and contact), add the additional columns to the Group By statement.
Once we have all the unique columns, we can negate the above, selecting the rows that don't match the columns we selected above:
SELECT * FROM your_table_name
WHERE id NOT IN (
SELECT *
FROM (
SELECT MAX(id)
FROM your_table_name
GROUP BY username
)
)
Again, test that this is actually selecting the rows you want to delete, then change the SELECT * to DELETE. No guarantees on the correctness of my statements so hopefully you aren't using this on a production system or at least one you can't afford to delete something you shouldn't have.