Below is the SQL query of the survey results of 19 films released in 2026 based on 20 participants. The results are limited to the films with over 10 users entering a valid rating:
SELECT
u.user_id,
m.movie_name,
m.genre,
r.rating
FROM ratings r
JOIN users u ON r.user_id = u.user_id
JOIN movies m ON r.movie_id = m.movie_id
WHERE m.movie_id IN (
SELECT movie_id
FROM ratings
GROUP BY movie_id
HAVING COUNT(user_id) >= 10
)
ORDER BY r.rating DESC;
Below is the R code to load in the survey results from the CSV file:
survey_results <- "https://raw.githubusercontent.com/shanicesmith98/data-607-assignments/refs/heads/main/week-2-assignment/latest_movies_survey_results_2a.csv"
df <- read.csv(survey_results)
head(df)
## user_id movie_name genre rating
## 1 4 Spider-Man: Brand New Day Superhero 5
## 2 9 Obsession Horror 5
## 3 15 Obsession Horror 5
## 4 15 Spider-Man: Brand New Day Superhero 5
## 5 19 The Sheep Detectives Comedy 5
## 6 4 Spider-Man: Brand New Day Superhero 5
colnames(df)
## [1] "user_id" "movie_name" "genre" "rating"
str(df)
## 'data.frame': 161 obs. of 4 variables:
## $ user_id : int 4 9 15 15 19 4 19 20 4 4 ...
## $ movie_name: chr "Spider-Man: Brand New Day" "Obsession" "Obsession" "Spider-Man: Brand New Day" ...
## $ genre : chr "Superhero" "Horror" "Horror" "Superhero" ...
## $ rating : int 5 5 5 5 5 5 5 5 5 5 ...
summary(df$rating)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 1.000 3.000 4.000 3.832 5.000 5.000