几个小问题.
1.
select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where b.hwid not in (select hwid from tgmy.ht_ruk_hwls c where c.zt='预分配')
and Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >= '01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2),substr(b.hwcode,8,1) ,substr(b.hwcode,1,7) desc
或
select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where not exists (select 1 from tgmy.ht_ruk_hwls c where c.zt='预分配' and b.hwid = c.hwid)
and Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >= '01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2),substr(b.hwcode,8,1) ,substr(b.hwcode,1,7) desc
执行时,有时速度快,有时速度会慢上好几倍。(相同条件下,数据量都不超过3000条)
2.
select * from
(select * from tgmy.c_hwda a
where a.hwid not in (select hwid from tgmy.ht_d_hwfp) ) b
where b.hwid not in (select hwid from tgmy.ht_ruk_hwls c where c.zt='预分配')
and Length(trim(b.hwcode))>=8 and substr(b.hwcode,1,2) >='01' and substr(b.hwname,1,1) <> 'X'
order by substr(b.hwcode,1,2), substr(b.hwcode,8,1),substr(b.hwcode,1,7) desc;
如何取出第一条。
3.
在存储过程中,建立临时表;多个人同时运行这个存储过程,会不会有影响。