select 学号, 
sum(if(课程 = '语文',成绩,0)) as 语文成绩,
sum(if(课程 = '数学',成绩,0)) as 数学成绩
from 成绩表
group by 学号
order by 学号