你要留下什么样的数据?或者你要删除什么样的数据? --如下,留下 时间最大的数据 delete from table where (a,b,c,date,e,f,g) not in (select a,b,c,max(date),e,f,g from table group by a,b,c,e,f,g)
先用分组的方法将冗余数据找出来。然后用1楼的方法删除冗余数据DELETE FROM TABLE WHERE DATE NOT IN (SELECT MAX(date) AS DATE FROM ( SELECT DATE FROM TABLE GROUP BY DATE HAVING(COUNT(1)>1)) t)
删除重复数据,只保留一条:delete from tablename table1 where rowid < (select max(rowid) from tablename table2 where table1.a = table2.a and table1.b = table2.b and table1.c = table2.c and table1.e = table2.e and table1.f = table2.f and table1.g = table2.g)
--如下,留下 时间最大的数据
delete from table where (a,b,c,date,e,f,g) not in
(select a,b,c,max(date),e,f,g from table group by a,b,c,e,f,g)
SELECT DATE FROM TABLE GROUP BY DATE HAVING(COUNT(1)>1)) t)
where rowid < (select max(rowid)
from tablename table2
where table1.a = table2.a
and table1.b = table2.b
and table1.c = table2.c
and table1.e = table2.e
and table1.f = table2.f
and table1.g = table2.g)