General Solution....

  • 1

    The key of this problem is the student key is not primary, so the table may have two identical rows.
    Using DISTINCT would solve this problem.

    SELECT class
    FROM (
    SELECT DISTINCT student, class
    FROM courses
    ) AS C
    GROUP BY class
    HAVING COUNT(*) >=5

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.