SELECT DISTINCT H.ORDER_NO , H.BUSINESS_UNIT , H.SOLD_TO_CUST_ID , S.NAME1 , V.LIST_PRICE + V.PRICE + V1.LIST_PRICE + V2.LIST_PRICE , H.CURRENCY_CD_BASE FROM PS_ORD_HEADER H , PS_ORD_LINE L , PS_CUSTOMER S , PS_GST_ORDER_VW1 V , PS_GST_ORDER_VW2 V1 , PS_GST_ORDER_VW3 V2 , PS_SET_CNTRL_REC D WHERE H.BUSINESS_UNIT = L.BUSINESS_UNIT AND H.BUSINESS_UNIT = V.BUSINESS_UNIT AND H.BUSINESS_UNIT = V1.BUSINESS_UNIT AND L.BUSINESS_UNIT = V.BUSINESS_UNIT AND L.BUSINESS_UNIT = V1.BUSINESS_UNIT AND V.BUSINESS_UNIT = V1.BUSINESS_UNIT AND H.BUSINESS_UNIT = V2.BUSINESS_UNIT AND V.BUSINESS_UNIT = V2.BUSINESS_UNIT AND V1.BUSINESS_UNIT = V2.BUSINESS_UNIT AND L.BUSINESS_UNIT = V2.BUSINESS_UNIT AND H.ORDER_NO = L.ORDER_NO AND L.ORDER_NO = V.ORDER_NO AND L.ORDER_NO = V1.ORDER_NO AND H.ORDER_NO = V.ORDER_NO AND H.ORDER_NO = V1.ORDER_NO AND V.ORDER_NO = V1.ORDER_NO AND H.ORDER_NO = V2.ORDER_NO AND L.ORDER_NO = V2.ORDER_NO AND V.ORDER_NO = V2.ORDER_NO AND V1.ORDER_NO = V2.ORDER_NO AND H.SOLD_TO_CUST_ID = S.CUST_ID AND H.BUSINESS_UNIT = D.SETCNTRLVALUE AND S.SETID = D.SETID AND D.RECNAME = 'CUSTOMER' AND H.BUSINESS_UNIT = ( SELECT DISTINCT P.BUSINESS_UNIT FROM PS_ORG_BU_TAX_APPL P WHERE P.ORG_BU_TYPE IN ('OM','AR') AND P.STX_OTC_APPL = 'Y' AND P.BUSINESS_UNIT = H.BUSINESS_UNIT AND L.BUSINESS_UNIT = P.BUSINESS_UNIT)
|