my dataframe
ID COURSE_ID SEC_ID SEMESTER YEAR GRADE
00128 CS-101 1 Fall 2009 A
00128 CS-347 1 Fall 2009 A-
12345 CS-101 1 Fall 2009 C
....
I want to get course_id & sec_id with the maximum number of registrants(count(id)) at 2009 fall.
so, I tried
select course_id, sec_id, enrollment
from (select course_id, sec_id, count(ID) as enrollment
from takes
where semester = 'Fall' and year = 2009
group by course_id, sec_id)
However, this will result in each class having registrants. I want to show only those classes with the maximum number of registrants. I think I need to use max, but now I need to solve it with subsection of this code, from.(from subquery)
++ Can I solve it using the having clause? I would appreciate it if you could let me know if you can.
thank you for reading.