我正在尝试列出在秋季学期至少参加一门课程或在春季学期至少参加一门课程的学生,但不能同时参加这两个课程。我试图从不同的角度来解决这个问题,但到目前为止我还没有成功。我觉得完成此解决方案的代码如下。任何帮助表示赞赏!
SELECT enrolled.StudentID, student.LastName, student.FirstName
, enrolled.courseID, enrolled.Quarter
FROM enrolled
INNER JOIN student ON enrolled.studentID = student.SID
GROUP BY enrolled.StudentID, student.LastName, student.FirstName
, enrolled.courseID, enrolled.Quarter
HAVING (count(distinct enrolled.Quarter) = 1)