create view vname as select t1.zd1,t1.c1,t2.c2 from (select zd zd1,count(1) c1 from a group by zd) t1,
(select zd zd2,count(1) c2 from b group by zd) t2
where t1.zd1 = t2.zd2(+);

解决方案 »

  1.   

    create or replace view count_view as
    select zd, sum(zd_count1) a_count,sum(zd_count2) b_count from
    (
    select zd, count(*) zd_count1, 0 zd_count2 from a group by zd
    uinon all
    select zd, 0 zd_count1, count(*) zd_count2 from b group by zd
    ) c
    group by zd
      

  2.   

    "要找出二表中相同字段的值"什么意思?两表的结构相同,字段也是相同的吧?是不是要找出具有相同值的记录?select a.* from a, b where a.zd=b.zd 是不是这么简单?
      

  3.   

    那是
    select * from a
    union all 
    select * from b这样?