Search code examples
sqlinner-joinoracle-apexfrequency

Combining FREQUENCY count and INNER CASE in SQL


How do I combine both in order to show the student name (sname) and section number (sectno) for a class that has more than 6 student? So far I have this

SELECT student.sname, enroll.sectno,

FROM student

INNER JOIN enroll 

ON student.sid=enroll.sid

with

SELECT grade, 

COUNT(grade)AS Frequency

FROM enroll

GROUP BY grade

HAVING COUNT(grade)>6

Solution

  • looks like you were very close. I think the below should work for you:

    SELECT 
    student.sname, 
    enroll.sectno,
    COUNT(enroll.grade) AS Frequency
    FROM student
    INNER JOIN enroll ON student.sid=enroll.sid
    GROUP BY student.sname, enroll.sectno
    HAVING COUNT(enroll.grade)>6