用ORACLE如何做 一个类似用友财务的余额表?就是最后一列余额显示让  期初余额 +借方-贷方,
如:create table [t1](code varchar(5),debit (借方)  int,credit(货方 ) int,balance(余额)  int) 
insert [t1] 
select '00001',null,null,0 union all 
select '00001',100,0,0 union all 
select '00001',0,200,0 union all 
select '00001',100,200,0 union all 
select '00002',0,0,0 union all 
select '00002',200,0,0 union all 
select '00002',0,100,0 create table [temp1]([客户编号] varchar(5),[余额] int) 
insert [temp1] 
select '00001',1000 union all 
select '00002',6000 得到如下结果:
客户编号  借方          货方          余额           
----- ----------- ----------- -----------  
00001 NULL        NULL        1000 
00001 100         0           1100 
00001 0           200         900 
00001 100         200         800 
00002 0           0           6000 
00002 200         0           6200 
00002 0           100         6100