I have 2 tables enroll(sid, grade, dname, cno, sectno) and student(sid, sname, sex, age, year, gpa)
I have to write query asking for the ids of students that took only sections that had more than 10 students in them.
Why this query is not giving me correct result?
select student.sid
from student
where student.sid IN (select student.sid
from enroll
group by sectno, cno, dname
having count (distinct enroll.sid) > 10)
What about this query, is it correct?
select distinct sid
from enroll e1
where 10 < (select count (*)
from enroll e2
where e2.sectno = e1.sectno
and e2.cno = e1.cno
and e2.dname = e1.dname)
order by sid