
2个回答
展开全部
应该有,等会,我测试一下,有思路了
--create table b1
--(
--a int,
--b int,
--c int
--)
--create table b2
--(
--a int ,
--b int ,
--d int
--)
--insert into b1
--select 1,1,2 union all
--select 3,2,1 union all
--select 4,2,2
--insert into b2
--select 2,1,1 union all
--select 4,2,2
go
select * from b1
go
select * from b2
select a,b,sum(c) as c from
(
select a ,b,c from b1
union all
select a,b,d as c from b2) aa
group by a,b
)
--create table b1
--(
--a int,
--b int,
--c int
--)
--create table b2
--(
--a int ,
--b int ,
--d int
--)
--insert into b1
--select 1,1,2 union all
--select 3,2,1 union all
--select 4,2,2
--insert into b2
--select 2,1,1 union all
--select 4,2,2
go
select * from b1
go
select * from b2
select a,b,sum(c) as c from
(
select a ,b,c from b1
union all
select a,b,d as c from b2) aa
group by a,b
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询