Print the course names, course numbers and section numbers of all classes with l
ID: 3651769 • Letter: P
Question
Print the course names, course numbers and section numbers of all classes with less than six students enrolled in them.I tried...
SELECT cname, sectno, e.cno, count(Distinct(sid)) as "Number of Students"
FROM Enroll e, Course c WHERE c.cno=e.cno and c.cno=e.cno
Group by e.cno, sectno, c.cname having Count(Distinct(sid))<6
However it gives me no results. Just the column name.
I would appreciate being showed how to find the course name, course number, and section number of all classes with less than six students enrolled in them.
Here are the Tables...
Student(sid,sname,sex,age,year,qpa)
Dept(dname,numphds)
Prof (pname,dname)
Course (cno,cname,dname)
Major(dname,sid)
Section(dname,cno,sectno,pname)
Enroll(sid,grade,dname,cno,sectno)
Explanation / Answer
Try - select count(*), s.dname, c.cno, s.sectno from section s, enroll e, course c where s.sectno = e.sectno and e.cno = c.cno group by s.dname, c.cno, s.sectno having count(*) > 6;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.