50分求,如何连接多表
A表
1 2 3
5 8
B表
10 15
c表
200 250
205 255
210 260
要求生成
D表
1 2 3 10 15 200 250
5 8 205 255
210 260
并将各字段汇总求和。生成D表中有无null无所谓
问题点数:50、回复次数:3Top
1 楼libin_ftsafe(子陌红尘:TS for Banking Card)回复于 2005-06-03 22:05:50 得分 50
select identity(int,1,1) as id,* into #t1 from A表
select identity(int,1,1) as id,* into #t2 from B表
select identity(int,1,1) as id,* into #t3 from C表
select
a.col1,
a.col2,
a.col3,
b.col1,
b.col2,
c.col1,
c.col2
from
(select id from #t1
union
select id from #t2
union
select id from #t3) v
left join
#t1 a
on
v.id = a.id
left join
#t2 b
on
v.id = b.id
left join
#t3
on
v.id = c.idTop
2 楼hlzwq()回复于 2005-06-03 22:26:31 得分 0
正在按阁下的思路理解。不过求和我还不会Top
3 楼hlzwq()回复于 2005-06-04 19:57:18 得分 0
我自己解决了Top




