这条sql语句执行的速度相当慢啊,有没有什么地方可以优化一下,哪怕提高一点点速度也行啊,谢谢select min(right(code,4)) from customer
where code like 'US%' and right(code,4)+1 not in(select right(code,4) from customer);
where code like 'US%' and right(code,4)+1 not in(select right(code,4) from customer);
left join customer b on right(a.code,4)+1=right(b.code,4)
where a.code like 'US%' and b.code is null
where code like 'US%' and right(code,4)+1 not in(select right(code,4) from customer);的结果贴出来看一下。
not in 想办法改成not exists