有如下表结构:
table1
en_name bs_code money1 money2
------- ------- ------ ------
008001 2010101 1000 800
008001 2010102 5000 4000
008001 2010201 23000 4300
008001 2080101 23450 546
007001 2020101 23200 340
007001 2020201 23200 340
通过sql查询变成如下汇总结果:
en_name bs_code money1 money2
------- ------- ------ ------
008001 52450 9646
201 29000 9100
20101 6000 4800
2010101 1000 800
2010102 5000 4000
20102 23000 4300
2010201 23000 4300
208 23450 546
20801 23450 546
2080101 23450 546
007001 46400 680
202 46400 680
20201 23200 340
2020101 23200 340
20202 23200 340
2020201 23200 340
========================
创建测试表结构:
create table TEST
(
EN_NAME VARCHAR2(6),
BS_CODE VARCHAR2(10),
MONEY1 NUMBER,
MONEY2 NUMBER
);
insert into test t values('008001','2010101',1000,800);
insert into test t values('008001','2010102',5000,4000);
insert into test t values('008001','2010201',23000,4300);
insert into test t values('008001','2080101',23450,546);
insert into test t values('007001','2020101',23200,340);
insert into test t values('007001','2020201',23200,340);
commit;