For this assignment we were suppose to conduct a survey asking at least 5 people to rate the last 10 movies on a scale of 1-5. For this survey I asked 10 people which consist of some co-workers and friends to rate they most recent movies. After everyone complete the survey I record the result and upload. The results for the survey is available for download from either google.com or github.com using the link below:
dbGetQuery(con,'
SELECT *
FROM Most_recent_Movies_Rating
')
dbGetQuery(con, '
SELECT SCORE, COUNT(SCORE)
FROM Most_recent_Movies_Rating
GROUP BY SCORE
ORDER BY COUNT(SCORE) DESC
')
dbGetQuery(con, '
SELECT Most_recent_Movies_Rating.SCORE, Most_recent_Movies_Rating.TITLE
FROM Most_recent_Movies_Rating
JOIN (SELECT SCORE, TITLE as opponent from Most_recent_Movies_Rating) B
ON Most_recent_Movies_Rating.SCORE = b.SCORE
ORDER BY Most_recent_Movies_Rating.SCORE DESC
')
SELECT Most_recent_Movies_Rating.SCORE, Most_recent_Movies_Rating.TITLE
FROM Most_recent_Movies_Rating
JOIN (SELECT SCORE, TITLE as opponent from Most_recent_Movies_Rating) B
ON Most_recent_Movies_Rating.SCORE = b.SCORE
ORDER BY Most_recent_Movies_Rating.SCORE DESC
Most_recent_Movies_Rating.db = tbl(con, "Most_recent_Movies_Rating")
Most_recent_Movies_Rating_query <- Most_recent_Movies_Rating.db %>%
select(SCORE, TITLE, MAIN_GENRE) %>%
left_join(Most_recent_Movies_Rating.db %>% select(MAIN_GENRE, SCORE = TITLE))
Most_recent_Movies_Rating_query %>% show_query()
SELECT
`Most_recent_Movies_Rating_LHS`.`SCORE` AS `SCORE`,
`Most_recent_Movies_Rating_LHS`.`TITLE` AS `TITLE`,
`Most_recent_Movies_Rating_LHS`.`MAIN_GENRE` AS `MAIN_GENRE`
FROM `Most_recent_Movies_Rating` AS `Most_recent_Movies_Rating_LHS`
LEFT JOIN `Most_recent_Movies_Rating` AS `Most_recent_Movies_Rating_RHS`
ON (
`Most_recent_Movies_Rating_LHS`.`SCORE` = `Most_recent_Movies_Rating_RHS`.`TITLE` AND
`Most_recent_Movies_Rating_LHS`.`MAIN_GENRE` = `Most_recent_Movies_Rating_RHS`.`MAIN_GENRE`
)
| SCORE | TITLE | MAIN_GENRE |
|---|---|---|
| 4.6 | Orion and The Dark | Comedy/Adventure |
| 4.5 | The BeeKeeper | Action/Thriller |
| 2.8 | Night Swim | Horror |
| 3.5 | Lift | Comedy/Action |
| 3.3 | Justice League: Crisis on Infinite Earth Part One | Animation |
| 3.1 | The Bricklayer | Action/Thriller |
| 3.0 | Badland Hunters | Action |
| 3.8 | Mean Girls | Musical/Comedy |
| 3.9 | Role Play | Action/Thriller |
| 4.0 | The Tiger’s Apprentice | Action/Adventure |
For this lab I took data from a survey that I conducted and inserted it in R build in SQL database. Base on the rating we can that Orion and the Dark have the highest rating followed by the BeeKeeper then The Tiger’s Apprentice.