我有一个怪异的表调用 mytable ,没有列是主要的。
Name | Company | Position Michael Google Tester Michael Google Tester Michael Google Tester Peter Facebook Developer Peter Facebook Developer Peter Facebook Developer Peter Facebook Developer
我想要的是
Name | Company | Position Michael Google Tester Peter Facebook Developer
对于一些我在此处遇到相同问题的解决方案,它们没有用。例如: DELETE FROM mytable WHERE Name NOT IN (SELECT MAX(Name) FROM mytable GROUP BY Company);
DELETE FROM mytable WHERE Name NOT IN (SELECT MAX(Name) FROM mytable GROUP BY Company);
我应该在此表中进行正确的编辑,使用SQLite,不要创建新表,也不要使用CTE。我该怎么做?
您可以选择保留min或max中rowid通过所示的3列编组。
min
max
rowid
delete from myTable where rowid not in (select min(rowid) from myTable group by name,company,position)