From 401589d3045f3d1b0ba2e5461a78f6b969cbf2a8 Mon Sep 17 00:00:00 2001 From: ivanbyone Date: Thu, 10 Jul 2025 11:15:40 +0300 Subject: [PATCH] task: #1050 --- README.md | 1 + ...rs Who Cooperated At Least Three Times.sql | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 leetcode/easy/1050. Actors and Directors Who Cooperated At Least Three Times.sql diff --git a/README.md b/README.md index 4face7b..43f9975 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ Useful for preparing for technical interviews and improving your SQL skills. - [619. Biggest Single Number](./leetcode/easy/619.%20Biggest%20Single%20Number.sql) - [620. Not Boring Movies](./leetcode/easy/620.%20Not%20Boring%20Movies.sql) - [627. Swap Salary](./leetcode/easy/627.%20Swap%20Salary.sql) + - [1050. Actors and Directors Who Cooperated At Least Three Times](./leetcode/easy/1050.%20Actors%20and%20Directors%20Who%20Cooperated%20At%20Least%20Three%20Times.sql) - [1068. Product Sales Analysis I](./leetcode/easy/1068.%20Product%20Sales%20Analysis%20I.sql) - [1075. Project Employees I](./leetcode/easy/1075.%20Project%20Employees%20I.sql) - [1141. User Activity for the Past 30 Days I](./leetcode/easy/1141.%20User%20Activity%20for%20the%20Past%2030%20Days%20I.sql) diff --git a/leetcode/easy/1050. Actors and Directors Who Cooperated At Least Three Times.sql b/leetcode/easy/1050. Actors and Directors Who Cooperated At Least Three Times.sql new file mode 100644 index 0000000..806b52d --- /dev/null +++ b/leetcode/easy/1050. Actors and Directors Who Cooperated At Least Three Times.sql @@ -0,0 +1,27 @@ +/* +Question 1050. Actors and Directors Who Cooperated At Least Three Times +Link: https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/description/?envType=problem-list-v2&envId=database + +Table: ActorDirector + ++-------------+---------+ +| Column Name | Type | ++-------------+---------+ +| actor_id | int | +| director_id | int | +| timestamp | int | ++-------------+---------+ +timestamp is the primary key (column with unique values) for this table. + + +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. +*/ + +SELECT + actor_id, + director_id +FROM ActorDirector +GROUP BY (actor_id, director_id) +HAVING COUNT(1) >= 3