안녕하세요!
이번 포스팅은 LeetCode에 있는 Actors and Directors Who Cooperated At Least Three Times 문제를 OracleDB로 풀어보려고 합니다!
(모든 문제는 Oracle로 풀이하겠습니다.)
1. 문제 링크 : https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/description/
2. 문제
| Column name | Type |
| actor_id | int |
| director_id | int |
| timestamp | int |
[문제] Write a solution to find all the pairs (actor_id, director_id) where the actor has cooperated with the director at least three times.
배우가 감독과 최소 3번 이상 협력한 모든 쌍(actor_id, director_id)을 조회하는 문제입니다.
3. 제출 쿼리 및 설명
최종) 배우와 감독 ID를 묶어서 그룹화하고, 최소 3번 이상 협력한 배우와 감독 ID를 조회합니다.
SELECT ACTOR_ID, DIRECTOR_ID
FROM ACTORDIRECTOR
GROUP BY ACTOR_ID, DIRECTOR_ID
HAVING COUNT(*) >= 3
;
'SQL > LeetCode' 카테고리의 다른 글
| [SQL] Product Sales Analysis III(LeetCode/Oracle) (0) | 2023.10.19 |
|---|---|
| [SQL] Product Sales Analysis I(LeetCode/Oracle) (0) | 2023.10.19 |
| [SQL] Customers Who Bought All Products(LeetCode/Oracle) (0) | 2023.10.18 |
| [SQL] Swap Salary(LeetCode/Oracle) (0) | 2023.10.18 |
| [SQL] Exchange Seats(LeetCode/Oracle) (0) | 2023.10.18 |