How to select students that failed at least at all courses that student with id = 1 failed?
1
vote
2
answers
3498
views
I have the following tables:
STUDENT (student_id, first_name, last_name, birth_date, year , domain)
PROFESSOR (professor_id, first_name, last_name, birth_date, hire_date, title, salary)
COURSE (course_id, course_name, professor_id)
GRADE (student_id, course_id, grade, date_of_exam)
I have to display the students that failed at least at all the courses that student with
id = 1
failed.
What I tried:
SELECT
s.student_id,
s.first_name,
s.last_name,
n.grade,
n.course_id
FROM
student s
JOIN grade n ON n.student_id = s.student_id
WHERE
n.grade <= 4;
...this gets all the students that failed but I don't know how to go from this to all the students that failed at least at all the courses that student with id = 1
failed. If someone could point me in the right direction I would be grateful!
**Additional details**
For example: If student with id = 1
failed at courses with ids = 2,3
. And we have other two students who failed at courses with ids = 2,3
(like student 1) and they might fail at other courses too, then I want to display those two students.
Asked by Eduard Valentin
(13 rep)
May 23, 2018, 07:15 PM
Last activity: Mar 9, 2023, 01:41 PM
Last activity: Mar 9, 2023, 01:41 PM