用sql语句 case when来解答这道题,谢谢!

2025-01-07 02:58:04
推荐回答(1个)
回答1:

SELECT Name
,SUM(CASE Course WHEN '语文' THEN Score ELSE 0 END) AS [语文]

,SUM(CASE Course WHEN '数学' THEN Score ELSE 0 END) AS [数学]

,SUM(CASE Course WHEN '英语' THEN Score ELSE 0 END) AS [英语]

FROM Score
GROUP BY Name