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

Car pooling app

 I'll create a car pooling app with real-time vehicle tracking, pickup/drop time estimates, and a list of onboard users. Since we don...