Created
July 17, 2019 15:04
-
-
Save Shaddyjr/1e0577c5120b7584f3a32644d2339392 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH subq (actor_1_id, actor_2_id, film_id) AS | |
(SELECT p1.actor_id, p2.actor_id, p2.film_id | |
FROM film_actor p1 | |
JOIN film_actor p2 | |
ON p1.film_id = p2.film_id | |
AND p1.actor_id < p2.actor_id | |
) | |
SELECT actor_1_id, actor_2_id, COUNT(film_id) AS count | |
FROM subq | |
GROUP BY actor_1_id, actor_2_id | |
HAVING COUNT(film_id) = ( | |
SELECT MAX(xxx.mycount) | |
FROM ( | |
SELECT actor_1_id, actor_2_id, COUNT(film_id) AS mycount | |
FROM subq | |
GROUP BY actor_1_id, actor_2_id | |
) AS xxx | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment