${IF(isSubLot=\"yes\",\" select t2.lot_id,t1.ROUTE_ID,t1.OPERATION_ID,t2.IN_QTY,t2.OUT_QTY,t2.yield from (SELECT T.STEP_SEQ,ROUTE_ID,OM.OPERATION_ID FROM (SELECT P.ROUTE_ID,P.OPERATION_RRN, MIN(P.STEP_SEQ) STEP_SEQ FROM PROCESS_WORKFLOW_SUMM P, PROCESS_MASTER PM WHERE P.PROCESS_RRN = PM.PROCESS_RRN -- AND P.PROCESS_VERSION = PM.CURRENT_VERSION AND P.PROCESS_VERSION = \'\"+ver+\"\' AND EXISTS (SELECT 1 FROM PRODUCT_PROCESS_MASTER PPM, PRODUCT_MASTER PM WHERE P.PROCESS_RRN = PPM.PROCESS_RRN and PPM.PRODUCT_RRN = PM.PRODUCT_RRN AND pm.product_id = \'\"+productId+\"\' ) group BY P.ROUTE_ID,P.OPERATION_RRN) T, OPERATION_MASTER OM WHERE T.OPERATION_RRN = OM.OPERATION_RRN) t1, (SELECT t.lot_id, t.route_id, t.operation_id, sum(t.move_in_qty1) IN_QTY, sum(t.move_out_qty1) OUT_QTY, round(decode(nvl(sum(t.move_in_qty1), 0), 0, 0, nvl(sum(t.move_out_qty1), 0) / nvl(sum(t.move_in_qty1), 0)), 6) yield FROM (select T.LOT_ID, T.STEP_SEQUENCE, T.ROUTE_ID, T.OPERATION_ID, T.MOVE_IN_QTY1, T.MOVE_OUT_QTY1, RANK() OVER(PARTITION BY T.LOT_RRN,T.ROUTE_ID, T.OPERATION_RRN order by T.STEP_SEQUENCE DESC) R from lot_step_history t, LOT_MASTER LM, p2rptda1.workorder wo,P2RPTDA1.Item i where t.move_out_qty1 is not null and lm.product_rrn = i.item_rrn(+) AND lm.Outer_Order_No = \'\"+orderNo+\"\' AND WO.WORK_ORDER_TYPE = \'\"+orderType+\"\' AND i.Encapsulated_Type = \'\"+encapsulatedType+\"\' AND lm.product_id = \'\"+productId+\"\' AND lm.LOT_ID = \'\"+lotId+\"\' AND T.PROCESS_VERSION = \'\"+ver+\"\' AND T.LOT_RRN = LM.LOT_RRN and lm.outer_order_no = wo.workorder_id(+) ) T WHERE R = 1 group by t.lot_id, t.route_id, t.operation_id) t2 where t1.ROUTE_ID = t2.ROUTE_ID(+) and t1.OPERATION_ID= t2.OPERATION_ID(+) order by t1.STEP_SEQ\",\"select 2 from dual\")}SQL里AND lm.Outer_Order_No = \'\"+orderNo+\"\' AND WO.WORK_ORDER_TYPE = \'\"+orderType+\"\' AND i.Encapsulated_Type = \'\"+encapsulatedType+\"\' AND lm.product_id = \'\"+productId+\"\' AND lm.LOT_ID = \'\"+lotId+\"\' AND T.PROCESS_VERSION = \'\"+ver+\"\' 这几个加上if(len) 判断