关于一句SQL语句,希望大神帮我简化下。
由于查询太过费时导致程序很卡,所以希望大神们帮我看下,如何优化这句SQL语句!谢谢了select distinct(t1.stackId) FROM [test].[dbo].[stackAssemb] t1
where t1.assembNum =(select MAX(t2.assembNum) FROM [test].[dbo].[stackAssemb] t2
where t2.stackNum =t1.stackNum) and t1.workorder ='WO-STK0134' and t1.stackId not in
( select from [test].[dbo].[stackInventory] t3 where t3.AC ='入库'
and t3.timesNum =1 and t3.wo ='WO-STK0134' union select stackId from stackTest
where testType='post' and workorder ='WO-STK0134' )and t1.stackId in
(select stackId from stackTest where testType='pre' and type2='叠阵' and workorder ='WO-STK0134')