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

remove duplicates in an sorted array

  using System; public class HelloWorld {          public static void Main(string[] args)     {         int[] ar={2,2,3,3,4,6,6};          C...