sql server - Uisng exists in sql to find duplicates, is there a cleaner way? -
see script below find duplicates in sql server db. there cleaner way?
select itemnum matusetrans exists (select null matusetrans b a.itemnum = b.itemnum , a.actualdate = b.actualdate , a.matusetransid != b.matusetransid , (a.rotassetnum = b.rotassetnum or (a.rotassetnum null , b.rotassetnum null)) , a.quantity = b.quantity) group itemnum
another possibility (but not neccessarily "cleaner") might be
with cte as( select columns, row_number() on (partition columns order columns) rowidx matusetrans group columns ) select * cte rowidx > 1
Comments
Post a Comment