sql语句突然执行要很长时间
select t3.CustomerName,t5.TypeName,t4.SheetColor,t4.SheetFab,t4.SheetFabD, t4.Thickness,t4.SheetNorm,t4.Style,
t6.Name as UnitName,t2.OrderDate,t2.BillNO,t1.Quantity as NQuantity,t1.Price,t1.Remarks,
t1.Quantity-ISNULL((select SUM(t7.Number) from tbInStorageDetail as t7 left join tbInStorage as t8 on t7.InStorageID=t8.ID
where t7.RelatedOrderNO=t1.BillNO and t7.GoodsID=t4.ID and t8.CheckStatus=2),0) as Quantity
from tbSaleQuotationDetail as t1
left join tbSaleQuotationList as t2 on t1.BillNO=t2.BillNO
left join tbCustomer as t3 on t3.CustomerID=t2.CustomerID
left join tbProduct as t4 on t4.ProductID=t1.ProductNO
left join tbType as t5 on t5.ID=t4.Type
left join tbUnit as t6 on t6.ID=t4.Unit
where (t1.EndStatus != 1 or t1.EndStatus = 2 ) and t2.CheckStatus=2 and
t1.Quantity-ISNULL((select SUM(t7.Number) from tbInStorageDetail as t7 left join tbInStorage as t8 on t7.InStorageID=t8.ID
where t7.RelatedOrderNO=t1.BillNO and t7.GoodsID=t4.ID and t8.CheckStatus=2),0) > 0