Wednesday, 12 March 2025

duplicates

 with cte as(

SELECT EMPID, Forminfoid, FormName,

       ROW_NUMBER() OVER (PARTITION BY EMPID, Forminfoid,FormName ORDER BY EMPID) AS RowNum

FROM tbl_FilesMigrationLogs)

select * from cte where rownum >1

filtering based on 3 columns duplicates

--USing having can't delete in cte due to aggrigate function..

so use below rownumber....

with cte as(

SELECT EMPID, Forminfoid, FormName,

       ROW_NUMBER() OVER (PARTITION BY EMPID, Forminfoid,FormName ORDER BY EMPID) AS RowNum

FROM tbl_FilesMigrationLogs)

delete from cte where rownum >1


here empid,formid,formname have duplicate data





No comments:

Post a Comment

Enviri JD for BI

  Job Description: Experience working closely with business users/leaders. Well-versed in requirement gathering and can lead business users ...