In recent interviews, I encountered such a database question:
Delete duplicate data in the table, and keep only one duplicate data.
Ideas:
1) This question needs to use the rowid, first find the rowid of the duplicate data, and find the maximum or minimum value of the rowid as a condition for deletion;
select min(rowid) from aa group by Name having count(Name) > 1
2) Find the name with a number greater than 1 according to the name
select name from aa group by name having count(name) > 1
3) Perform the delete operation according to the above two conditions
delete from aa t where t.name in (select name from aa group by name having count(name) > 1)
and rowid not in (select min(rowid) from aa group by Name having count(Name) > 1);