我正在尝试查询以查找不止一次采访的学生的所有详细信息
我已经使用以下方法成功获得了结果:
SELECT S.StudNo, S.StudLName, S.StudFName, S.StudMobile, S.City, S.DateEnrolled, S.ProgNo, S.AmountDue, S.Gender
FROM STUDENT AS S INNER JOIN STUDENT_INTERVIEW AS SI ON S.StudNo = SI.StudID
WHERE
(SELECT COUNT(SI.StudID)
FROM STUDENT_INTERVIEW)
GROUP BY S.StudNo, S.StudLName, S.StudFName, S.StudMobile, S.City, S.DateEnrolled, S.ProgNo, S.AmountDue, S.Gender
HAVING COUNT(SI.StudID) > 1;
但它似乎太长了..我正在尝试重写它以使其不那么罗嗦,尽管无法获得正确的结果。我一直在尝试使用更多的子查询而不必使用GROUP BY
. 当我这样做时,我会得到所有学生的结果,而不是我所追求的特定 2
SELECT *
FROM STUDENT
WHERE StudNo IN
(SELECT StudID
FROM STUDENT_INTERVIEW
WHERE
(SELECT COUNT(StudID)
FROM STUDENT_INTERVIEW
HAVING COUNT(StudID) > 1;))