91% RUNTIME | Beginner freindly | SQL |GROUP BY, HAVING✅✅✅| Easy to understand
Intuitionselect class as we have to return it.
from the courses table
apply group by on the class because we have to to return the class that have more than or
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nselect class as we have to return it.\nfrom the courses table\napply group by on the class because we have to to return the class that have more than or 5 student enrolled. \nwe can not apply "where" when we use "group by" instead we use having then we counted the distinct student using "count";\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\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 []\n# Write your MySQL query statement below\nselect class\nfrom courses\ngroup by class\nhaving count(distinct student)>=5;\n\n```
['MySQL']