--try;select a.单位编号,a.收入-b.收入 差 from 
(
  select rownum no,单位编号,收入 from tb
) a,
(
  select rownum no,单位编号,收入 from (select '000' 单位编号,0 收入 from dual union all 
                           select 单位编号,收入 from tb)
) b
where a.no=b.no;

解决方案 »

  1.   

    哪里,只是在CSDN上学习学习^_^
      

  2.   

    SQL> create table tb(no varchar2(4),fee number(10));Table createdSQL> insert into tb values('0001',5000);1 row insertedSQL> insert into tb values('0002',6000);1 row insertedSQL> insert into tb values('0003',5600);1 row insertedSQL> insert into tb values('0004',4000);1 row insertedSQL> insert into tb values('0005',3000);1 row insertedSQL> insert into tb values('0006',7000);1 row insertedSQL> insert into tb values('0007',4500);1 row insertedSQL> commit;Commit completeSQL> select * from tb;NO           FEE
    ---- -----------
    0001        5000
    0002        6000
    0003        5600
    0004        4000
    0004        3000
    0004        7000
    0004        45007 rows selectedselect no,fee from tb where rownum<2
      union
    select a.no,fee1-fee2 from
    (
      select no,fee fee1,rownum id1 from tb order by rownum desc
    )a,
    (   
      select no,fee fee2,rownum id2 from
      (
        select no,fee from tb where rownum<(select count(*) from tb)
      ) order by rownum desc
    )b
    where a.id1=b.id2+1
    NO          FEE
    ---- ----------
    0001       5000
    0002       1000
    0003       -400
    0004      -1600
    0005      -1000
    0006       4000
    0007      -25007 rows selected
      

  3.   

    ORARichard(没钱的日子......) 的可以
      

  4.   

    ORARichard(没钱的日子......) 有QQ不!给我撒!有什么不会的找你哦!!!
      

  5.   

    我用MSN:[email protected]
    可以互相交流