我有一个SQL查询,我想从课程表中选择idLesson列大于MAX的来自出勤表idLesson的行。如何更正此查询?
SELECT student.userid, lessons.idLesson, student.fee, lessons.datePassed
FROM student
Inner JOIN `project_course`.group ON group.idGroup = student.idGroup
Inner JOIN lessons ON group.idGroup=lessons.idGroup
Inner JOIN attendance ON lessons.idLesson>MAX(attendance.idLesson)
group by lessons.idlesson;
答案 0 :(得分:1)
这是根据您的解释修改的查询
其中idLesson列大于MAX来自idLesson的出勤率 表
SELECT student.userid, lessons.idLesson, student.fee, lessons.datePassed
FROM student
Inner JOIN `project_course`.group ON group.idGroup = student.idGroup
Inner JOIN lessons ON group.idGroup=lessons.idGroup
WHERE lessons.idLesson >
( SELECT MAX(attendance.idLesson)
FROM attendance
)