时间查询条件区间查询

SELECT COUNT(1)
  FROM (SELECT w.log_name,
               w.cust_party_id,
               w.creation_date,
               row_number() over(PARTITION BY w.cust_party_id ORDER BY w.creation_date DESC) rn
          FROM cop_work_log w
         WHERE w.project_no IS NULL
           AND w.or_line_id IS NULL) cwl,
       cop_customer_header_v h,
       cop_fae_customer_assign ass,
       cop_cop_my_attention atten
 WHERE 1 = 1
   AND cwl.rn(+) = 1
   AND cwl.cust_party_id(+) = h.cust_party_id
   AND h.cust_party_id = ass.cust_party_id(+)
   AND(cwl.creation_date >= to_date(l_date_f, 'YYYY-MM-DD') or l_date_f is null)
   AND(cwl.creation_date <= to_date(l_date_t, 'YYYY-MM-DD') or l_date_t is null)
   AND ass.assign_person_id = 4012
   AND h.cust_party_id = atten.object_id(+)
   AND atten.attend_type(+) = 0

posted @ 2017-06-06 16:57  albert_think  阅读(1250)  评论(0编辑  收藏  举报