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

Popular posts from this blog

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -