检查 Logic Java 课程最近一次考试。如果有成绩到达80分以上者,则显示分数排在前5名学员的学号和分数

时间:2021-05-26 23:17:14

检查 Logic Java 课程最近一次考试。如果有成绩到达80分以上者,则显示分数排在前5名学员的学号和分数

SELECT studentNO 学号,studentResult 成绩
FROM result
WHERE EXISTS(
#查询Logic java 最后一次考试成绩大于80的记录
SELECT * FROM result WHERE subjectNo = (
#查询Logic Java 课程的编号
SELECT subjectNO FROM SUBJECT WHERE subjectName = ‘Logic Java’
)AND examDate = (
#查询最近一次Logic Java 考试时间
SELECT MAX(examDate) FROM result WHERE subjectNo = (
SELECT subjectNo FROM SUBJECT
WHERE subjectName = ‘Logic Java’
)
)AND studentResult > 80)
AND subjectNo = (
查询Logic Java 课程的编号
SELECT subjectNO FROM SUBJECT WHERE subjectName = ‘Logic Java’
)
按成绩降序排序,显示前5名
ORDER BY studentResult DESC LIMIT 5;