我需要从具有 30 列的表中删除确切的重复记录。我的数据看起来像是附加的。提前谢谢!
问问题
316 次
2 回答
1
你的问题我是这样理解的...
1)如果您只想从重复行中删除一条记录。在这种情况下,您需要在表中包含(当前时间戳)的列日期
delete from tableName t1 where
t1.id in (SELECT t2.id
FROM tableName t2
where t1.id = t2.id and t1.date(timestamp) < t2.date(timestamp))
2)如果你想删除完整的重复行
delete from tableName t1 where
t1.id in (SELECT t2.id
FROM tableName t2
group by t2.id
having count(*) >1)
于 2013-06-13T11:02:13.577 回答
0
这个应该工作:
delete from <table>
where rowid IN (
SELECT LEAD(rowid) OVER (PARTITION BY <col1>, <col2>,...,<coln> ORDER BY NULL)
FROM <table>
);
当然还有小提琴
于 2013-06-13T11:42:03.987 回答