34,588
社区成员
发帖
与我相关
我的任务
分享
select * from View_data t where ([CompanyName] like '%limited' or [Email] like '%cn') and not exists(select 1 from View_data where ([CompanyName] like '%limited' or [Email] like '%cn') and CompanyName=t.CompanyName and [AutoID] >t.[AutoID])
select * from View_data t where ([CompanyName] like '%limited' or [Email] like '%cn')
and [AutoID]= (select max([AutoID]) from View_data where [CompanyName] like '%limited' or [Email] like '%cn' and CompanyName=t.CompanyName)
select * from View_data t where ([CompanyName] like '%limited' or [Email] like '%cn') and not exists(select 1 from View_data where CompanyName=t.CompanyName and [AutoID] >t.[AutoID])
你使用的是like本来效率就不怎么样,在CompanyName上都建上索引吧。