有没有办法删除所有重复的行和excel或access中的原始条目?
我需要删除匹配 3 列的整行。这是一个视觉效果(底部表格是表格应该成为的样子;在这种情况下,具有相同零件编号、制造商和制造编号的副本 + 原件将被删除):
问问题
763 次
3 回答
2
这在 Access 中似乎对我有用:
DELETE FROM parts
WHERE EXISTS
(
SELECT p2.[PART NUMBER], p2.[MANUFACTURER], p2.[MANUFACTURER NUMBER]
FROM parts p2
WHERE parts.[PART NUMBER] = p2.[PART NUMBER]
AND parts.[MANUFACTURER] = p2.[MANUFACTURER]
AND parts.[MANUFACTURER NUMBER] = p2.[MANUFACTURER NUMBER]
GROUP BY p2.[PART NUMBER], p2.[MANUFACTURER], p2.[MANUFACTURER NUMBER]
HAVING COUNT(*) > 1
)
当我在我的测试数据上运行它时......
PART NUMBER MANUFACTURER QUALITY MANUFACTURER NUMBER
----------- ------------ ------- -------------------
123 GORD 1 750
123 OTHER 3 321
123 OTHER 4 321
...它删除了两个“其他”行,但单独留下了“GORD”行。
于 2013-06-10T21:01:50.367 回答
0
DELETE * FROM MyTable WHERE PartNumber in (SELECT MyTable.PartNumber
FROM MyTable
GROUP BY MyTable.PartNumber
HAVING (((Sum(1))>1)));
于 2013-06-10T20:18:41.467 回答
0
这应该为你做。它检查所有三个字段,并删除原始和所有重复项。
DELETE
parts.*
FROM parts
WHERE (( ((SELECT Count (*)
FROM parts AS P
WHERE ( P.partnum & P.manf & P.manfnum =
parts.partnum & parts.manf & parts.manfnum )
AND ( P.partnum <= parts.partnum ))) > 1 ));
于 2013-06-10T21:11:09.627 回答