select Name,
sum(case Course when '语文' then Gradeid else '0' end) as 语文,
sum(case Course when '数学' then Gradeid else '0' end) as 数学,
sum(case Course when '英语' then Gradeid else '0' end) as 英语
from student
group by Name
select Name,
sum(case Course when '语文' then Gradeid else '0' end) as 语文,
sum(case Course when '数学' then Gradeid else '0' end) as 数学,
sum(case Course when '英语' then Gradeid else '0' end) as 英语
from student
group by Name
case when语法写的有点儿问题
try
select Name,
sum(case when Course = '语文' then Gradeid else 0 end) as 语文,
sum(case when Course = '数学' then Gradeid else 0 end) as 数学,
sum(case when Course = '英语' then Gradeid else 0 end) as 英语
from student
group by Name