create view c as
select decode(id_type,1,a.id,2,a.req),a.req,b.date1
from a,b
where 关联条件

解决方案 »

  1.   

    create view c as 
    select a.id,a.req,b.date1
    from a,b
    where b.id_type=1 and b.pid=a.id
    union
    select a.id,a.reg,b.date1
    from a,b
    where b.id_type=2 and b.req=a.id;
      

  2.   

    嗯。还有个问题,就是有的ID值在A中存在,但在B中该值还不存在,其他的条件跟上述相同,我想把这部分值也在视图中可查到,该怎么改上述创建语句?谢谢
      

  3.   

    create view c as 
    select a.id,a.req,b.date1
    from a,b
    where b.id_type=1 and a.id=b.pid(+)
    union
    select a.id,a.reg,b.date1
    from a,b
    where b.id_type=2 and a.id=b.req(+);