我正在尝试从学生获得成绩的课程中选择课程编号
首先,我为每个 Grade_type_code 选择学生在哪里获得成绩
SELECT z.STUDENT_ID ,m.GRADE_TYPE_CODE,COUNT(*) AS COURSE_NUM
FROM STUDENT z, GRADE m,SECTION s, COURSE w
WHERE z.STUDENT_ID = m.STUDENT_ID
AND m.SECTION_ID = s.SECTION_ID
AND s.COURSE_NO = w.COURSE_NO
GROUP BY z.STUDENT_ID,m.GRADE_TYPE_CODE
比我尝试做的左外连接
SELECT COURSE_NO
FROM COURSE lt
LEFT OUTER JOIN
(SELECT z.STUDENT_ID ,m.GRADE_TYPE_CODE,COUNT(*) AS COURSE_NUM
FROM STUDENT z, GRADE m,SECTION s, COURSE w
WHERE z.STUDENT_ID = m.STUDENT_ID
AND m.SECTION_ID = s.SECTION_ID
AND s.COURSE_NO = w.COURSE_NO
GROUP BY z.STUDENT_ID,m.GRADE_TYPE_CODE) rt
ON lt.COURSE_NO = rt.COURSE_NO;