I have 3 tables, “users”, “movies”, and “events”
CREATE TABLE users (user_id INTEGER PRIMARY KEY, user_name TEXT,first_name TEXT, last_name TEXT, address TEXT, city TEXT, stateTEXT)
CREATE TABLE movies (movie_id INTEGER PRIMARY KEY, movie_nameTEXT, movie_score TEXT)
CREATE TABLE events (user_id INTEGER, movie_id INTEGER,date_watched TEXT)
The primary key for the events table is the concatenation ofuser_id, movie_id, date_watched. A user could have watched one ormore movies, one or more times. A movie could be watched by one ormore users, one or more times.
Write a SQL query for the following questions:
For each user_name, provide the latest date that they watchedany movie and the name of the movie they watched.
How would you include a column for the average number of moviesper user, and then find each users variance from the mean of thepopulation?
Prepare a list of the top 10 users with the highest averagemovie score (this is the average movie score of the movies theyhave watched). Include only the first and last name as a singlefield for each user.
Answer to Using SQL: I have 3 tables, “users”, “movies”, and “events” CREATE TABLE users (user_id INTEGER PRIMARY KEY, user_name T…