SELECT 学号, 姓名, max(iif(科目='语文',分数,0)) AS 语文, max(iif(科目='数学',分数,0)) AS 数学, max(iif(科目='外语',分数,0)) AS 英语, max(iif(科目='物理',分数,0)) AS 物理, sum(分数) AS 总分
FROM 成绩
GROUP BY 学号, 姓名;
自己想出来了谢谢
SELECT 学号, 姓名, sum(iif(科目='语文',分数,0)) AS 语文, sum(iif(科目='数学',分数,0)) AS 数学, sum(iif(科目='外语',分数,0)) AS 英语, sum(iif(科目='物理',分数,0)) AS 物理, sum(分数) AS 总分 FROM 成绩 GROUP BY 学号, 姓名