问你们个数据库问题
id 9月
1001 10
1002 12表2
id 10月
1001 10
1002 20
1003 30表3
id 11月
1002 10
1003 20
整合成表4
id 9月 10月 11月
1001 10 10
1002 12 20 10
1003 30 20该怎么做
id 9月
1001 10
1002 12表2
id 10月
1001 10
1002 20
1003 30表3
id 11月
1002 10
1003 20
整合成表4
id 9月 10月 11月
1001 10 10
1002 12 20 10
1003 30 20该怎么做
from a,b,c
where a.id = b.id(+)
and a.id = c.id(+)
假如表结构为(id number,num number),表名分别为a,b,c
可以
select t.id,a.num "9月",
b.num "10月",
c.num "11月"
from
(select id from a union
select id from b union
select id from c)t,
a,b,c
where t.id=a.id(+)
and t.id=b.id(+)
and t.id=c.id(+)
或
select nvl(t.id,c.id)id,"9月","10月",c.num "11月"
from
(select nvl(a.id,b.id)id,
a.num "9月",b.num "10月"
from a full join b
on a.id=b.id)t
full join c
on t.id=c.id
select id, sum(9月) 9月, sum(10月) 10月, sum(11月) 11月
from (
select id, 9月, null 10月, null 11月 from t1
union all
select id, null 9月, 10月, null 11月 from t1
union all
select id, null 9月, null 10月, 11月 from t1)
group by id