select t5.friendid,
       t6.friend_name,
       t5.contractnumber,
       t5.total_value,
       t5.start_date,
       t5.end_date,
       t6.emp_name as salename,
       t6.dept_name,
       t6.friend_phone
  from (select t1.cust_id          as friendId,
               t1.so_code          as contractnumber,
               t1.so_amount        as TOTAL_VALUE,
               t1.so_delivery_date as START_DATE,
               t1.so_PAYMENT_DATE  as END_DATE
          from tc_sales_order_m t1
         where t1.so_payment_date + 7 > sysdate
           and t1.so_payment_date < sysdate) t5,
       (select t2.emp_id, t4.emp_name,t3.dept_name,t7.friend_phone, t3.biz_dept_id, t2.friend_id, t7.friend_name
          from rel_friend_emp t2,
               tc_department  t3,
               tc_employee    t4,
               tc_friend      t7
         where t2.emp_id = t4.emp_id
           and t3.dept_id = t4.dept_id
           and t2.owner_id = 1
           and t3.owner_id = 1
           and t4.owner_id = 1
           and t7.owner_id = 1
           and t2.friend_id = t7.friend_id
           and t3.biz_dept_id = '110') t6
 where t5.friendid = t6.friend_id(+);