select a, max(a1), max(a2)
from (select a,
case
when b = '语文' then
c
else
null
end as a1,
case
when b = '数学' then
c
else
null
end as a2
from (select name a, subject b, score c from studentinfo) x) y
group by a;
select a, case when b = '语文' then c else null end as a1,
case when b = '数学' then c else null end as a2
b = '数学' then c else null end as a2这句开头也要case when