This commit is contained in:
louiscklaw
2025-01-31 22:17:25 +08:00
parent cdc3678990
commit 3688f9ee24
100 changed files with 65454 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
SELECT
cast1.cast_id AS cast_member_id1,
cast2.cast_id AS cast_member_id2,
Count(cast1.movie_id) AS cocasted,
AVG(movie.score) AS avg_score
FROM movie_cast cast1
JOIN movie_cast cast2
ON cast1.movie_id = cast2.movie_id
JOIN movies movie
ON cast1.movie_id = movie.id
AND cast1.cast_id < cast2.cast_id
JOIN movies movie1
ON cast1.movie_id = movie1.id
GROUP BY cast1.cast_id, cast2.cast_id
HAVING cocasted >= 3 AND avg_score >= 40
ORDER BY cocasted DESC;