技术成就梦想

知道用户需求,做到专注!c#,donet,Frameworks,UML,面向对象,设计模式!
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

删除重复报告和回复

Posted on 2011-12-29 21:46  我不是高手  阅读(175)  评论(0编辑  收藏  举报

--删除重复报告
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