create table test as select * from khxy a,khxycs b where a.xyid=b.xyid;
是这样么?

解决方案 »

  1.   

    不是啊,我是这样做的。select distinct a.*,decode(csmc,'IP国内长折扣',cssz,0) ipgn,decode(csmc,'IP国际长折扣',cssz,0) ipgj,decode(csmc,'IP港澳台长折扣',cssz,0) ipgat,decode(csmc,'普通国内长折扣',cssz,0) ptgn,decode(csmc,'普通国际长折扣',cssz,0) ptgj,decode(csmc,'普通港澳台长折扣',cssz,0) ptgat from khxy a,khxycs b where a.xyid=b.xyid(+);但是结果是:
     XYID XYMC   IPGN   IPGJ  IPGAT  PTGN   PTGJ  PTGAT
        1 测试一  0      0      0     0      0     12%
        1 测试一  0      0      0     0      2%     0
        1 测试一  0      0      0     7.5%   0      0
        1 测试一  0      0      8%    0      0      0
        1 测试一  0      5%     0     0      0      0
        1 测试一  10%    0      0     0      0      0
        2 测试二  0      0      0     0      0      07 rows selected我想要的结果是
     XYID XYMC   IPGN   IPGJ  IPGAT  PTGN   PTGJ  PTGAT
        1 测试一  10%    5%     8%    7.5%   2%     12%
        2 测试二  0      0      0     0      0      0能实现吗
      

  2.   

    create table test as select a.XYID,a.XYMC,sum(b.IPGN),sum(b.IPGJ),sum(b.IPGAT),sum(b.  PTGN),sum(b.PTGJ),sum(b.PTGAT) from khxy a,khxycs b where a.xyid=b.xyid group by a.XYID,a.XYMC;
      

  3.   

    select a.*,
    (select cssz from khxycs b where a.xyid=b.xyid and b.csmc='IP国内长折扣') ipgn,
    (select cssz from khxycs b where a.xyid=b.xyid and b.csmc='IP国际长折扣') ipgj,
    (select cssz from khxycs b where a.xyid=b.xyid and b.csmc='IP港澳台长折扣') ipgat,
    (select cssz from khxycs b where a.xyid=b.xyid and b.csmc='普通国内长折扣') ptgn,
    (select cssz from khxycs b where a.xyid=b.xyid and b.csmc='普通国际长折扣') ptgj,
    (select cssz from khxycs b where a.xyid=b.xyid and b.csmc='普通港澳台长折扣') ptgat
    from khxy a