✅Simple Solution | ✅Using Group By and Having Clause| ✅ Explanation
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to find all the classes that have at least five students. We can achieve th
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to find all the classes that have at least five students. We can achieve this by grouping the rows in the table by the class column and counting how many students are enrolled in each class. We then filter the results to include only those classes with five or more students.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nGroup the data by the class column: This will allow us to group together all the students enrolled in the same class.\nUse the COUNT() function: This function counts the number of students in each group (class).\nFilter with the HAVING clause: To only include classes with five or more students, we use the HAVING clause to filter groups based on their size.\n\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```mysql []\nselect class from courses group by class having count(class) >= 5;\n\n```
['MySQL']