I'm currently taking a course and during one of the tests, I came across this question.
The math_students and english_students tables have the following columns:
student_id, grade, first_name, last_name
Using a subquery, find out what grade levels are represented in both the math and english classes.
The query I used was this.
select distinct grade
from math_students
where grade in (
select grade
from english_students
);
However, it was graded as incorrect and the correct answer was given as
SELECT grade
FROM math_students
WHERE EXISTS (
SELECT grade
FROM english_students
);
I would really appreciate it if someone could help me understand the difference in the two queries because the output was the same in both cases. Also, why doesn't the query contain distinct?