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)