SELECT DISTINCT BUSINESS_UNIT , SOURCE_BUS_UNIT , SHIP_TO_CUST_ID , SHIP_CUST_NAME1 FROM PS_IN_DEMAND WHERE IN_FULFILL_STATE BETWEEN '60' AND '70' AND BILL_OF_LADING = ' ' AND SHIP_TO_CUST_ID <> ' ' AND ((EXPORT = 'Y' AND DEMAND_SOURCE <> 'OM') OR ORDER_NO IN ( SELECT DISTINCT S.ORDER_NO FROM PS_IN_DEMAND S , PS_ORD_LINE L , PS_ORD_SCHEDULE C WHERE S.DEMAND_SOURCE = 'OM' AND S.IN_FULFILL_STATE BETWEEN '60' AND '70' AND S.SOURCE_BUS_UNIT = L.BUSINESS_UNIT AND S.ORDER_NO = L.ORDER_NO AND S.SOURCE_BUS_UNIT = C.BUSINESS_UNIT AND S.ORDER_NO = C.ORDER_NO AND S.SHIP_TO_CUST_ID <> ' ' AND (L.EXPORT = 'Y' OR C.EXPORT = 'Y')))
|