72. Frequent Actor-Director Duos
In the film industry, analyzing collaborations between actors and directors can help production houses identify successful pairs. These frequent collaborations may reflect strong creative chemistry and successful outcomes.
You are given a ActorDirector table:
āāāāāāāāāāāāāāā¦āāāāāāāāāāā ā Column Name ā Type ā ā āāāāāāāāāāāāāā¬āāāāāāāāāā⣠ā actor_id ā int ā āāāāāāāāāāāāāāā¼āāāāāāāāāāā ā director_id ā int ā āāāāāāāāāāāāāāā¼āāāāāāāāāāā ā timestamp ā int ā āāāāāāāāāāāāāāā©āāāāāāāāāāā
- actor_id: ID of the actor involved in the collaboration
- director_id: ID of the director involved in the collaboration
- timestamp: This ensures that each record is uniquely identified by the time it happened.
Write a query to find all (actor_id, director_id) pairs where the actor has worked with the director three or more times.
Example 1:
Example:
Input:
ActorDirector Table:
āāāāāāāāāāāā¦āāāāāāāāāāāāāā¦āāāāāāāāāāāā ā actor_id ā director_id ā timestamp ā ā āāāāāāāāāāā¬āāāāāāāāāāāāāā¬āāāāāāāāāāā⣠ā 1 ā 1 ā 0 ā āāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāā ā 1 ā 1 ā 1 ā āāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāā ā 1 ā 1 ā 2 ā āāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāā ā 1 ā 2 ā 3 ā āāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāā ā 1 ā 2 ā 4 ā āāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāā ā 2 ā 1 ā 5 ā āāāāāāāāāāāā¼āāāāāāāāāāāāāā¼āāāāāāāāāāāā ā 2 ā 1 ā 6 ā āāāāāāāāāāāā©āāāāāāāāāāāāāā©āāāāāāāāāāāā
Output:
āāāāāāāāāāāā¦āāāāāāāāāāāāāā ā actor_id ā director_id ā ā āāāāāāāāāāā¬āāāāāāāāāāāāā⣠ā 1 ā 1 ā āāāāāāāāāāāā©āāāāāāāāāāāāāā
Explanation:
- (1, 1) appears 3 times ā included.
- (1, 2) appears 2 times ā excluded.
- (2, 1) appears 2 times ā excluded.
Still unsure what the problem is asking ?
Letās go through a few more examples, step by step, to make it clearer.