SELECT name , MAX(CASE `SUBJECT` WHEN '数学' THEN score ELSE 0 END ) 数学, MAX(CASE `SUBJECT` WHEN '语文' THEN score ELSE 0 END ) 语文, MAX(CASE `SUBJECT` WHEN '英语' THEN score ELSE 0 END ) 英语 FROM table_a GROUP BY NAME;
SELECT name , MAX(CASE `SUBJECT` WHEN '数学' THEN score ELSE 0 END ) 数学, MAX(CASE `SUBJECT` WHEN '语文' THEN score ELSE 0 END ) 语文, MAX(CASE `SUBJECT` WHEN '英语' THEN score ELSE 0 END ) 英语 FROM table_a GROUP BY NAME;