create table #temp
(姓名 varchar(10),
类型 int,
统计数量 int
)
insert into #temp
select 'A','1','10' union all
select 'A','2','5' union all
select 'B','1','10' union all
select 'B','2','5'
select * from #temp
select 姓名,sum(case 类型 when 1 then 统计数量 when 2 then -统计数量 else 0 end) as 统计数量
from #temp
group by 姓名