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 1
AND NOT EXISTS (
SELECT 1
FROM GRADE g1
JOIN GRADE g2
ON g1.course_id = g2.course_id
WHERE g1.student_id = 1
AND g1.grade 4
);
Asked by Rajendra
(31 rep)
Mar 9, 2023, 02:08 PM
Last activity: Mar 11, 2023, 04:06 PM
Last activity: Mar 11, 2023, 04:06 PM