Skip to content

Conversation

@Anuska08
Copy link

hii

@janto-071022
Copy link

janto-071022 commented Jul 14, 2025

hi sujay bhowmik
sujaybhowmik07@gmai.com // due to less time i upload the answer in comment section
"final project submission"
-------//-----1. Easy-------\------
/a. List each movie's title, release_date, and its director's name/

sql
Copy
Edit
SELECT
m.title,
m.release_date,
d.name AS director_name
FROM
Movies m
JOIN
Directors d ON m.director_id = d.director_id;

/*b. Retrieve all movie titles where is_original = TRUE */

sql
Copy
Edit
SELECT
title
FROM
Movies
WHERE
is_original = TRUE;

/*c. Show every web series' title, start_date, and seasons */
sql
Copy
Edit
SELECT
title,
start_date,
seasons
FROM
WebSeries;
-------//----2. Medium----\--------

/*a. For each actor, count how many movies they've appeared in */
sql
Copy
Edit
SELECT
a.actor_id,
a.name,
COUNT(mc.movie_id) AS movie_count
FROM
Actors a
LEFT JOIN
MovieCast mc ON a.actor_id = mc.actor_id
GROUP BY
a.actor_id, a.name
ORDER BY
movie_count DESC;

/b. For each genre, calculate how many movies belong to it/
sql
Copy
Edit
SELECT
g.genre_id,
g.name,
COUNT(mg.movie_id) AS movie_count
FROM
Genres g
LEFT JOIN
MovieGenres mg ON g.genre_id = mg.genre_id
GROUP BY
g.genre_id, g.name
ORDER BY
movie_count DESC;

/c. Average rating for each series with at least 2 reviews/
sql
Copy
Edit
SELECT
ws.series_id,
ws.title,
ROUND(AVG(r.rating), 2) AS average_rating
FROM
WebSeries ws
JOIN
Reviews r ON ws.series_id = r.content_id AND r.content_type = 'SERIES'
GROUP BY
ws.series_id, ws.title
HAVING
COUNT(r.review_id) >= 2
ORDER BY
average_rating DESC;

/d. List all episodes of "Breaking Bad"/
sql
Copy
Edit
SELECT
season_number,
episode_number,
title,
air_date
FROM
Episodes
WHERE
series_id = 101
ORDER BY
season_number, episode_number;

------// --3. Hard -----\--------

/a. Rank movies by their average review rating/

sql
Copy
Edit
SELECT
m.movie_id,
m.title,
ROUND(AVG(r.rating), 2) AS average_rating,
RANK() OVER (ORDER BY AVG(r.rating) DESC) AS rank
FROM
Movies m
JOIN
Reviews r ON m.movie_id = r.content_id AND r.content_type = 'MOVIE'
GROUP BY
m.movie_id, m.title;

/b. Combine movies and series with average rating ≥ 9.0/

sql
Copy
Edit
SELECT
'MOVIE' AS content_type,
m.title,
ROUND(AVG(r.rating), 2) AS average_rating
FROM
Movies m
JOIN
Reviews r ON m.movie_id = r.content_id AND r.content_type = 'MOVIE'
GROUP BY
m.title
HAVING
AVG(r.rating) >= 9.0

UNION

SELECT
'SERIES' AS content_type,
ws.title,
ROUND(AVG(r.rating), 2) AS average_rating
FROM
WebSeries ws
JOIN
Reviews r ON ws.series_id = r.content_id AND r.content_type = 'SERIES'
GROUP BY
ws.title
HAVING
AVG(r.rating) >= 9.0;

/c. Average rating per director for movies with ≥ 8.5/

sql
Copy
Edit
SELECT
d.name AS director_name,
ROUND(AVG(r.rating), 2) AS average_rating
FROM
Directors d
JOIN
Movies m ON d.director_id = m.director_id
JOIN
Reviews r ON m.movie_id = r.content_id AND r.content_type = 'MOVIE'
GROUP BY
d.name
HAVING
AVG(r.rating) >= 8.5;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants