请参阅下面的脚本以查找SQL Server DB中的重复项。有更清洁的方式吗?
select itemnum
from matusetrans a
where exists (select null
from matusetrans b
where a.itemnum = b.itemnum
and a.actualdate = b.actualdate
and a.matusetransid != b.matusetransid
and (a.rotassetnum = b.rotassetnum
or (a.rotassetnum is null and b.rotassetnum is null))
and a.quantity = b.quantity)
group by itemnum
答案 0 :(得分:1)
你可以尝试:
SELECT itemnum
FROM matusetrans
GROUP BY [ColumnNames]
HAVING
COUNT(*) > 1
答案 1 :(得分:1)
假设您要在表格中找到重复的itemnum,请使用以下查询
SELECT itemnum
FROM matusetrans
GROUP BY [ItemNum]
HAVING COUNT(ItemNum) > 1
使用HAVING COUNT(*) > 1
可能会为您提供结果,因为如果有任何Datetime
列,例如订单日期时间,这些列通常因每条记录而异。
谢谢, SREE
答案 2 :(得分:0)
另一种可能性(但不一定是“清洁”)可能是
*.svg