Table_1
Table_2
create procedure TempCal
as
Begin
create table #temp (id varchar(15),total1_tab1 int,total2_tab1 int)
insert into #temp select * from Table_1
insert into #temp select * from Table_2
select A.id,sum(convert(int,A.total1_tab1)),sum(convert(int,A.total2_tab1))
from #temp A group by A.id
end
go
And then to Execute:
exec TempCal
Result:
Table_2
create procedure TempCal
as
Begin
create table #temp (id varchar(15),total1_tab1 int,total2_tab1 int)
insert into #temp select * from Table_1
insert into #temp select * from Table_2
select A.id,sum(convert(int,A.total1_tab1)),sum(convert(int,A.total2_tab1))
from #temp A group by A.id
end
go
And then to Execute:
exec TempCal
Result:
0 comments:
Post a Comment