DQL
SELECT testName '学生名称',
sum(score)'科目总分数',
count(testName)'科目考试人数',
avg(score)'科目平均成绩',
max(score)'科目最高分',
min(score)'科目最低分'#最后一个列信息不写[,]
FROM result
WHERE studentId<5
GROUP BY testName
HAVING avg(score)>70
ORDER BY avg(score) desc;
SELECT studentId '学号',userName'学生姓名',introduce'学生简介',
sum(score)'学生各科目总成绩',
count(score)'学生参与考试科目数量',
avg(score)'学生所有科目平均成绩',
max(score)'学生所有科目最高分',
min(score)'学生所有科目中最低分'
FROM result INNER JOIN student on result.studentId=student.id
WHERE sex='男'
GROUP BY studentId,userName,introduce
HAVING avg(score)<60
ORDER BY avg(score) desc;
SELECT *FROM result INNER JOIN student on result.studentId=student.id;
标签:result,studentId,多表,查询,score,学生,联合,avg,科目
From: https://blog.csdn.net/2301_80888367/article/details/137502883