- 论坛徽章:
- 0
|
表建立:
table A
(
lsh char(20),
je number
)
table B
(
xh1 char(10),
xh2 char(10),
lsh char(20),
je number,
inum int,
bwh char(10),
)
1.建立临时表1
select xh1,xh2,sum(je) je1 from
(
select b.xh1,b.xh2,a.je
from
(select je from A where lsh in (select lsh from B where inum=10)) a,
B b
where a.lsh=b.lsh
)
group by xh1,xh2 into temp tmp_table1;
2.建立临时表2
select xh1,xh2,sum(je) je2 from B where bwh='10100' group by xh1,xh2 into temp tmp_table2;
3.临时表做并集
select a.je1,b.je2 from tmp_table1 a,tmp_table2 b where a.xh1=b.xh1 and a.xh2=b.xh2;
请问有什么好的方法把上面3个语句整合到1条语句实现? |
|