문제
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2Ff243fee6-b90d-40c1-a373-d536ff4d797f%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-23%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%205.48.24.png)
풀이
- there is a table courses with coluns: student and class
- please list out all classes which have more than or equal to 5 students.
- for example, the table.
쿼리
SELECT class
FROM courses
GROUP BY class
HAVING COUNT(DISTINCT student) >= 5
결과
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2F9089f2a1-8112-4614-a5d2-584253d839a8%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-23%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%206.05.09.png)
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2Fc4402e4b-ea7d-47e0-af8e-d8026107b266%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-09-23%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%206.05.21.png)
출처 && 깃허브
leetcode
github