来晚了,顺便接点分~谢谢~有什么问题再提出来
select name ,sum(case when score>0 then score else 0 end )as ZScore,sum(case when score<0 then score else 0 end )as FScore from tablename group by name
create table T(name varchar(100), score int)
insert into T
select 'AA', 50 union all
select 'AA', -20 union all
select 'AA', 40 union all
select 'AA', -25
select
Name,
sum(case when Score>0 then Score else 0 end) as ZScore,
sum(case when Score<0 then Score else 0 end) as FScore
from T
group by Name