打赏

sql server删除重复数据,保留第一条

SELECT * FROM EnterpriseDataTools.Enterprise.CompanyMain
where CompanyNo in (select CompanyNo from EnterpriseDataTools.Enterprise.CompanyMain
group by CompanyNo having count(CompanyNo) > 1)
and Id not in (select max(Id) from EnterpriseDataTools.Enterprise.CompanyMain
group by CompanyNo having count(CompanyNo) > 1)

posted @ 2016-11-03 09:51  KiteRunner1988  阅读(688)  评论(0编辑  收藏  举报