select name,
max(case when kecheng='语文' then fenshu else null end) as '语文',
max(case when kecheng='数学' then fenshu else null end) as '数学',
max(case when kecheng='英语' then fenshu else null end) as '英语'
from aa group by name
或者
select name,
sum(case when kecheng='语文' then fenshu else null end) as '语文',
sum(case when kecheng='数学' then fenshu else null end) as '数学',
sum(case when kecheng='英语' then fenshu else null end) as '英语'
from aa group by name
sum(case when kecheng='语文' then fenshu else null end) as '语文',
是将得到的结果进行行转列求和的方式。