--Table1
Declare @t table(id int,A_count int)
insert @t select 1 ,10
union all select 1,10
union all select 2,20
union all select 2,20
-----table2
declare @t1 table(id int,B_count int)
insert @t1 select 1,10
union all select 2,15
--SQL
select A.id,A.a_count,B.B_count from
(
select id,sum(a_count) as A_count
from @t group by id) A
inner join @t1 B
on A.id=B.id