SELECT A.BUSINESS_UNIT ,A.SO_ID ,D.FEE_SCHEDULE ,B.FEE_PCT FROM PS_RS_SO_HDR A , PS_POTENTIAL_INCME B , PS_SET_CNTRL_REC C , PS_RS_SO_LINE D , PS_FO_ORDER_TYPE H WHERE A.BUSINESS_UNIT = D.BUSINESS_UNIT AND A.USER_ORDER_TYPE = H.USER_ORDER_TYPE AND H.ORDER_TYPE = 'C' AND A.SYSTEM_SOURCE = 'STF' AND A.SO_ID = D.SO_ID AND A.BUSINESS_UNIT = C.SETCNTRLVALUE AND C.RECNAME = 'POTENTIAL_INCME' AND C.SETID = B.SETID AND B.FEE_SCHEDULE = D.FEE_SCHEDULE AND B.SALARY_RANGE_MIN = ( SELECT MAX(E.SALARY_RANGE_MIN) FROM PS_POTENTIAL_INCME E WHERE E.SETID = C.SETID AND E.FEE_SCHEDULE = D.FEE_SCHEDULE AND E.SALARY_RANGE_MIN <= (D.SALARY_RANGE_MAX + D.INITIAL_COMP)) AND B.SALARY_RANGE_MAX = ( SELECT MIN(SALARY_RANGE_MAX) FROM PS_POTENTIAL_INCME F WHERE F.SETID = C.SETID AND F.FEE_SCHEDULE = D.FEE_SCHEDULE AND F.SALARY_RANGE_MAX >= (D.SALARY_RANGE_MAX + D.INITIAL_COMP))
|