写出mysql语句,多表查询,查询选修了数据结构课程并且成绩高于陈骥最高成绩的学生的学号,姓名,成绩。
时间: 2023-06-04 12:07:09 浏览: 115
SELECT student.id, student.name, score.score
FROM student
INNER JOIN score ON student.id = score.student_id
INNER JOIN course ON score.course_id = course.id
WHERE course.name = '数据结构' AND score.score > (SELECT MAX(score) FROM score WHERE course_id = course.id AND student_id = (SELECT id FROM student WHERE name = '陈骥')) AND student.id NOT IN (SELECT student_id FROM score WHERE course_id <> course.id OR score.score <= (SELECT MAX(score) FROM score WHERE course_id = course.id AND student_id = (SELECT id FROM student WHERE name = '陈骥')))
相关问题
写出最简单的写出mysql语句,多表查询,查询选修了数据结构课程并且成绩高于陈骥最高成绩的学生的学号,姓名,成绩。
SELECT s.学号, s.姓名, s.成绩
FROM 学生 s
INNER JOIN 选课 c ON s.学号 = c.学号
INNER JOIN 课程 k ON c.课程号 = k.课程号
WHERE k.课程名称 = '数据结构' AND s.成绩 > (SELECT MAX(成绩) FROM 学生 WHERE 姓名 = '陈骥')
ORDER BY s.成绩 DESC;
阅读全文