SELECT DISTINCT H.BUSINESS_UNIT , H.ORDER_NO , S.ORDER_INT_LINE_NO , S.SCHED_LINE_NBR , O.SOLD_TO_CUST_ID , S.CURRENCY_CD_BASE , %Round(%DecMult(S.NET_UNIT_PRICE_BSE, S.QTY_SCHEDULED), 4) FROM PS_ORD_HOLD H , PS_ORD_HEADER O , PS_ORD_SCHEDULE S WHERE H.BUSINESS_UNIT = O.BUSINESS_UNIT AND H.ORDER_NO = O.ORDER_NO AND H.BUSINESS_UNIT = S.BUSINESS_UNIT AND H.ORDER_NO = S.ORDER_NO AND ((H.ORDER_NO = S.ORDER_NO AND H.ORDER_INT_LINE_NO = 0 AND H.SCHED_LINE_NBR = 0) OR (H.ORDER_INT_LINE_NO <> 0 AND H.ORDER_INT_LINE_NO = S.ORDER_INT_LINE_NO AND H.SCHED_LINE_NBR = 0) OR (H.ORDER_INT_LINE_NO <> 0 AND H.SCHED_LINE_NBR <> 0 AND H.ORDER_INT_LINE_NO = S.ORDER_INT_LINE_NO AND H.SCHED_LINE_NBR = S.SCHED_LINE_NBR)) AND H.EFF_STATUS = 'A' AND H.HOLD_LEVEL <> 'W' AND O.ORDER_TYPE_CD = 'SO' AND S.ORD_SCH_STATUS IN ('O','P')
|