如图 ,WxWorkId, UserName, addDate 取年月日
如果这3个重复 则 update isdelete =1
update a
set isdelete =1
from tb a
where exists
(select 1 from tb b
where a.WxWorkId=b.WxWorkId
and a.UserName=b.UserName
and cast(a.addDate as date)=cast(b.addDate as date)
and a.id>b.id
)
update table-A
set IsDelete=1
from Table-A a
join(select ID=min(ID), WxWorkId, UserName, iDay=DateDiff(Day,0,addDate)
from Table-A
group by WxWorkId, UserName, DateDiff(Day,0,addDate)
) as b on a.WxWorkId=b.WxWorkId and a.UserName=b.UserName and DateDiff(Day,0,a.addDate)=b.iDay and a.ID>b.ID