Simple MySQL Solution
Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve this problem, we need to identify the classes that have at least 5 distinct st
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve this problem, we need to identify the classes that have at least 5 distinct students enrolled. We can achieve this by grouping the data by class and counting the number of distinct students in each group. Finally, we will filter out the classes that have fewer than 5 distinct students.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGroup by class: We will group the data by the class column to aggregate the number of students in each class.\nCount distinct students: Within each group, we will count the number of distinct students using the count(distinct student) function.\nFilter the results: We will use the having clause to filter out the classes that have fewer than 5 distinct students.\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\n# Write your MySQL query statement below\nselect class From Courses group by class having count(distinct student) >= 5;\n```
['MySQL']