删除重复报告和回复

--删除重复报告
Select * into #Tmp from Sms_SendHistoryReport
Select min(ReportID) as ReportID into #Tmp2 from #Tmp group by HistoryID,PhoneNum,State,SendTime,IsSended
Select * from #Tmp where ReportID in (Select ReportID from #Tmp2)

delete from Sms_SendHistoryReport where ReportID not in (Select ReportID from #Tmp2)

drop table #Tmp
drop table #Tmp2

原文地址:https://www.cnblogs.com/zxjyuan/p/2306692.html