LeetCode - 1050. Actors and Directors Who Cooperated At Least Three Times (MySQL)

조민수·2024년 6월 5일
0

LeetCode

목록 보기
14/64
post-custom-banner

Easy, SQL - 다중 조건 GROUP BY

RunTime : 329 ms


문제

Write a solution to find all the pairs (actor_id, director_id) where the actor has cooperated with the director at least three times.

Return the result table in any order.

The result format is in the following example.


풀이

  • 두 쌍이 함께 몇 번 나오는 지 확인해야 한다면, GROUP BY에 다중 조건을 걸 수 있다.
SELECT actor_id, director_id FROM ActorDirector
GROUP BY actor_id, director_id
HAVING COUNT(timestamp) >= 3
profile
사람을 좋아하는 Front-End 개발자
post-custom-banner

0개의 댓글