select b.name as 年级,sum(case when a.type='语文' then a.score else 0 end) as 语文总分数,sum(case when a.type='数学' then a.score else 0 end) as 数学总分数from a,b where a.gradeid=b.idgroup by b.name
select sum(score) from A group by gradeid,type