select name,sum([count]) as count
from (
select * from t1
union all select * from t2
) tmp
group by name
-------------------------------
佩服 paoluo(一天到晚游泳的鱼)
给人多种思路
顶!
create table t1(name varchar(3),con int)
insert t1 select 'a',3
union all select 'b',5
union all select 'c',3
create table t2(name varchar(3),con int)
insert t2 select 'a',2
union all select 'b',3
union all select 'd',4
select name ,sum(con) as con from(select * from t1
union all
select * from t2) t group by name
drop table t1
drop table t2