We will create a temporary view that we can easily refer to the data we want to include in our visualization. For this data, we can investigate whether there are any patterns in the ratings when grouped by month. To do that, we use the ROUND() and AVG() functions to calculate the average rating and limit it to 3 decimal places. Then, extract the month from the timeRecorded column after casting it as a timestamp. The AVG() is calculated over the course of a month, as specified in the GROUP BY clause.
CREATE
OR REPLACE TEMPORARY VIEW ratingsByMonth AS
SELECT
ROUND(AVG(rating), 3) AS avgRating,
month(CAST(timeRecorded as timestamp)) AS month
FROM
movieRatings
GROUP BY
month;