select * from (select a.id,a.lot_no,a.checklist_biz_type,lot.subcmpt_qty,w.wo_code,w.product_name,a.template_id,a.plannode_id, node.nodeobj_name nodeobj_name,node.node_seq,par.node_seq as par_seq,par.nodeobj_name stage_name from EDC_TRANSFER_CHECKLIST a left join mp_wip_lot lot on a.lot_no = lot.lot_no LEFT JOIN mp_wom_workorder w on lot.wo_id=w.id and a.wo_id = w.id left join mc_prp_plannode node on a.plannode_id = node.id left join mc_prp_plannode par on node.parnode_id = par.id
where-- a.lot_no='D21041701' --and (a.LOT_NO = '' or '' is null) and (w.product_name like '%%' or '' is null) and (node.nodeobj_name like '%%' or '' is null) and (par.nodeobj_name like '%%' or '' is null) and a.biz_status = 'Y' and a.checklist_biz_type = 'EDC' and a.DEL_FLAG = '0' and lot.del_flag='0' and w.del_flag='0' ) aa left join (SELECT a.biz_status, b.POSITION_NO, b.COMPONENT_SN, b.line_type, b.item_name, b.item_val, b.sample_cnt cnt, b.id as checkItemId, b.checklist_id FROM edc_transfer_checklist_item b left JOIN edc_transfer_checklist a on a.ID = b.CHECKLIST_ID WHERE
b.LINE_TYPE = 'Data' AND b.del_flag = '0' )bb on aa.id=bb.checklist_id left join ( select a.val_unit, a.template_id as temp_id, a.item_name, a.sample_size, a.sample_cnt, a.test_standard, CASE a.val_type WHEN 'NUM' THEN concat(concat(concat(concat(b.MIN_VAL, '<'), 'X'), '<='), b.MAX_VAL) WHEN 'NMD' THEN concat(concat(b.middle_val, '±'), b.delta_val) ELSE '' END as val from edc_check_template_item a left join edc_check_item_val b on a.id = b.template_item_id where a.del_flag='0' and b.del_flag = '0' )cc on aa.template_id=cc.temp_id and bb.item_name=cc.item_name where bb.biz_status is not null order by aa.lot_no,aa.wo_code,to_number(aa.par_seq),aa.stage_name,to_number(aa.node_seq),aa.nodeobj_name,aa.template_id,to_number(bb.POSITION_NO), bb.COMPONENT_SN,cc.item_name,to_number(bb.cnt),bb.item_val and ('2021-07-14' is null or a.collect_date >= to_date('2021-07-14', 'yyyy-mm-dd')) and ('2021-07-14' is null or a.collect_date <= to_date('2021-07-14', 'yyyy-mm-dd')) |