问题描述
- 怎样删除表中的重复数据,谢谢大家
-
表内容如下:
id fwbm kjbh sfxm dj yl .......................
52578 d01142 d011422015928 001 .400 0 54.70 54.70 0 0 2015-09-28 00:00:00.000 NULL
52579 d01142 d011422015928 040 2.990 2 5.98 5.98 0 0 2015-09-28 00:00:00.000 NULL
52580 d01142 d011422015928 042 1.000 2 2.00 2.00 0 0 2015-09-28 00:00:00.000 NULL
52581 d01142 d011422015928 001 .400 0 54.70 54.70 0 0 2015-09-28 00:00:00.000 NULL
52582 d01142 d011422015928 040 2.990 2 5.98 5.98 0 0 2015-09-28 00:00:00.000 NULL
52583 d01142 d011422015928 042 1.000 2 2.00 2.00 0 0 2015-09-28 00:00:00.000 NULL
52584 d01251 d012512015928 001 .400 0 54.70 54.70 0 0 2015-09-28 00:00:00.000 NULL
52585 d01251 d012512015928 040 2.990 2 5.98 5.98 0 0 2015-09-28 00:00:00.000 NULL
52586 d01251 d012512015928 042 1.000 2 2.00 2.00 0 0 2015-09-28 00:00:00.000 NULL
52587 d01251 d012512015928 001 .400 0 54.70 54.70 0 0 2015-09-28 00:00:00.000 NULL
52588 d01251 d012512015928 040 2.990 2 5.98 5.98 0 0 2015-09-28 00:00:00.000 NULL
52589 d01251 d012512015928 042 1.000 2 2.00 2.00 0 0 2015-09-28 00:00:00.000 NULL
52590 d01331 d013312015928 001 .400 0 54.70 54.70 0 0 2015-09-28 00:00:00.000 NULL
52591 d01331 d013312015928 040 2.990 2 5.98 5.98 0 0 2015-09-28 00:00:00.000 NULL
52592 d01331 d013312015928 042 1.000 2 2.00 2.00 0 0 2015-09-28 00:00:00.000 NULL
52593 d01331 d013312015928 001 .400 0 54.70 54.70 0 0 2015-09-28 00:00:00.000 NULL
52594 d01331 d013312015928 040 2.990 2 5.98 5.98 0 0 2015-09-28 00:00:00.000 NULL
52595 d01331 d013312015928 042 1.000 2 2.00 2.00 0 0 2015-09-28 00:00:00.000 NULL表中每一个fwbm,如d01142 前三行数据和后三行数据是重复的 现在想批量删除后三行 主键为ID列
解决方案
delete from 表名 a? where a.rowid NOT IN? (select max(b.rowid) from 表名 b?? where a.字段1 = b.字段1 and??a.字段2 = b.字段2?)......
答案就在这里:删除表中重复数据
----------------------
解决方案二:
非常感谢robot-s
时间: 2024-11-25 12:57:59