select *
  from (select a, b, c, d
          from t1
         where c like 'C%'
           and d like 'D'
        UNION
        select a, b, c, d
          from t1
         where c like 'C%'
           and d like 'D') a1,
       t2
 where a1.a = t2.a(+)
   and a1.b = t2.b(+)

解决方案 »

  1.   

    第一步:你首先得构造一个表temp,保存2011-5-01到2011-5-24,先保证日期值都能取到,不会有少的。其次,三个表通过日期进行关联,得到自己所要的字段就行了。
      

  2.   

    select *
      from (select a, b, c, d
              from t1
             where c like 'C%'
               and d like 'D'
            UNION
            select a, b, c, d
              from t1
             where c like 'C%'
               and d like 'D') a1 left join
           t2
     on a1.a = t2.a
       and a1.b = t2.b