34,576
社区成员
发帖
与我相关
我的任务
分享
select stuName,数学,语文,英语,总计
from (select *,sum(stuScroe)over(partition by stuName) 总计 from a) a
pivot(max(stuScroe) for stuClass in(数学,语文,英语))b
select stuName,
max(case stuClass when '数学' then stuScroe end) '数学' ,
max(case stuClass when '语文' then stuScroe end) '语文' ,
max(case stuClass when '英语' then stuScroe end) '英语' ,
总计
from (select *,总计=(select sum(stuScroe) from A where stuName=t.stuName) from A t) a
group by stuName,总计