File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -859,6 +859,7 @@ _If you like this project, please leave me a star._ ★
859
859
| 1075| [ Project Employees I] ( https://leetcode.com/problems/project-employees-i/ ) | [ Solution] ( ../master/database/_1075.sql ) | | Easy |
860
860
| 1069| [ Product Sales Analysis II] ( https://leetcode.com/problems/product-sales-analysis-ii/ ) | [ Solution] ( ../master/database/_1069.sql ) | | Easy |
861
861
| 1068| [ Product Sales Analysis I] ( https://leetcode.com/problems/product-sales-analysis-i/ ) | [ Solution] ( ../master/database/_1068.sql ) | | Easy |
862
+ | 1050| [ Actors and Directors Who Cooperated At Least Three Times] ( https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/ ) | [ Solution] ( ../master/database/_1050.sql ) || Easy |
862
863
| 627| [ Swap Salary] ( https://leetcode.com/problems/swap-salary/ ) | [ Solution] ( ../master/database/_627.sql ) | | Easy |
863
864
| 626| [ Exchange Seats] ( https://leetcode.com/problems/exchange-seats/ ) | [ Solution] ( ../master/database/_626.sql ) | | Medium |
864
865
| 620| [ Not Boring Movies] ( https://leetcode.com/problems/not-boring-movies/ ) | [ Solution] ( ../master/database/_620.sql ) | | Easy |
Original file line number Diff line number Diff line change
1
+ -- 1050. Actors and Directors Who Cooperated At Least Three Times
2
+ --
3
+ -- Table: ActorDirector
4
+ --
5
+ -- +-------------+---------+
6
+ -- | Column Name | Type |
7
+ -- +-------------+---------+
8
+ -- | actor_id | int |
9
+ -- | director_id | int |
10
+ -- | timestamp | int |
11
+ -- +-------------+---------+
12
+ -- timestamp is the primary key column for this table.
13
+ --
14
+ --
15
+ -- Write a SQL query for a report that provides the pairs (actor_id, director_id) where the actor have cooperated with the director at least 3 times.
16
+ --
17
+ -- Example:
18
+ --
19
+ -- ActorDirector table:
20
+ -- +-------------+-------------+-------------+
21
+ -- | actor_id | director_id | timestamp |
22
+ -- +-------------+-------------+-------------+
23
+ -- | 1 | 1 | 0 |
24
+ -- | 1 | 1 | 1 |
25
+ -- | 1 | 1 | 2 |
26
+ -- | 1 | 2 | 3 |
27
+ -- | 1 | 2 | 4 |
28
+ -- | 2 | 1 | 5 |
29
+ -- | 2 | 1 | 6 |
30
+ -- +-------------+-------------+-------------+
31
+ --
32
+ -- Result table:
33
+ -- +-------------+-------------+
34
+ -- | actor_id | director_id |
35
+ -- +-------------+-------------+
36
+ -- | 1 | 1 |
37
+ -- +-------------+-------------+
38
+ -- The only pair is (1, 1) where they cooperated exactly 3 times.
39
+
40
+ -- # Write your MySQL query statement below
41
+ select actor_id, director_id from ActorDirector
42
+ group by actor_id, director_id
43
+ having count (* ) >= 3 ;
You can’t perform that action at this time.
0 commit comments