SELECT DISTINCT C.corporate_setid , C.corporate_cust_id , C1.LANGUAGE_CD , C1.name1 FROM ps_customer C , PS_CUSTOMER_LANG C1 , ps_cust_data D , PS_CUST_CREDIT O WHERE C.SETID = C1.SETID AND C.CUST_ID = C1.CUST_ID AND c.cust_status = 'A' AND c.bill_to_flg = 'Y' AND c.cust_level <> 'P' AND C.setid = ( SELECT setid FROM ps_set_cntrl_rec WHERE setcntrlvalue = D.business_unit AND recname = 'CUSTOMER' ) AND C.cust_id = D.cust_id AND O.setid = C.corporate_setid AND O.cust_id = C.corporate_cust_id AND O.effdt = ( SELECT MAX(effdt) FROM PS_CUST_CREDIT WHERE setid = O.setid AND cust_id = O.cust_id AND effdt <= %CurrentDateIn AND eff_status = 'A' )
|