先行转列,然后你再 case when判断a,b,c;
select NAME ,
case when English >=90 then 'A' when English>=80 and English <90 then 'B' else 'C' end as English,
case when English >=90 then 'A' when Math>=80 and Math <90 then 'B' else 'C' end as Math,
case when English >=90 then 'A' when French>=80 and French <90 then 'B' else 'C' end as French,
case when English >=90 then 'A' when Chemistry>=80 and Chemistry <90 then 'B' else 'C' end as Chemistry
from (
SELECT
t1.NAME,
MAX( CASE t1.course WHEN 'English' THEN t1.GRADE ELSE 0 END ) English,
MAX( CASE t1.course WHEN 'Math' THEN t1.GRADE ELSE 0 END ) Math,
MAX( CASE t1.course WHEN 'French' THEN t1.GRADE ELSE 0 END ) French,
MAX( CASE t1.course WHEN 'Chemistry' THEN t1.GRADE ELSE 0 END ) Chemistry
FROM
STSCORE t1
GROUP BY
t1.NAME
) a