Monday, 10 March 2025

Duplicate records find and delete

 Check duplicate count based on 3 columns combo


select EMPID,FORMinfoID,FormName,Count(*) as counts from tbl_FilesMigrationLogs 

group by EmpID,FormInfoID,FormName

HAVING COUNT(*) >1; 

WITH CTE AS (
    SELECT EMPID,FORMinfoID,FormName,
           ROW_NUMBER() OVER (PARTITION BY EmpID, FormInfoID,FormName ORDER BY  EMPID) AS rn
    FROM tbl_FilesMigrationLogs
)
Select * FROM CTE WHERE rn > 1;

but for the both quries getting count different..

No comments:

Post a Comment

CMD expo

 › Metro waiting on exp://192.168.29.209:8081 › Scan the QR code above with Expo Go (Android) or the Camera app (iOS) › Using Expo Go › Pres...