tab1
id name total1
1 a 100
2 d 20
3 c 30
4 b 40
5 e 60
tab2
id name total2
1 a 100
2 p 1000
3 o 60
4 c 80
5 e 40结果
id name total1 total2
1 a 100 100
2 c 30 80
3 e 60 40
4 d 100
5 b 40
6 p 1000
7 o 60请教高手,用什么语句呀??先谢谢了
id name total1
1 a 100
2 d 20
3 c 30
4 b 40
5 e 60
tab2
id name total2
1 a 100
2 p 1000
3 o 60
4 c 80
5 e 40结果
id name total1 total2
1 a 100 100
2 c 30 80
3 e 60 40
4 d 100
5 b 40
6 p 1000
7 o 60请教高手,用什么语句呀??先谢谢了
select t1.name, t1.total1, t2.total2 from tab1 t1, tab2 t2 where t1.name= t2.name
union
select t1.name, t1.total1, null from tab1 t1 where t1.name not in(select t2.name from tab2 t2)
union
select t2.name, null, t2.total1 from tab2 t2 where t2.name not in(select t1.name from tab1 t1)
select ROWNUM AS ID ,a.* from (
select tab1.NAME,tab1.total1, tab2.total2 FROM TAB1 FULL JOIN TAB2 ON
TAB1.NAME=TAB2.NAME
union
select tab2.NAME,tab1.total1, tab2.total2 FROM TAB1 FULL JOIN TAB2 ON
TAB1.NAME=TAB2.NAME) a
where a.name is not null
union
select b.name,a.total1,b.total2 from tab1 a, tab2 b where tab1.name(+)=tab2.name我用的全外连接没出来,数据执行到死下了,