(Solved) : Using Sql 3 Tables Users Movies Events Create Table Users Userid Integer Primary Key Usern Q42775956 . . .

Using SQL:

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, state TEXT)CREATE TABLE movies (movie_id INTEGER PRIMARY KEY, movie_name TEXT, 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 that would provide the answer for each of thefollowing questions:

  1. Prepare a list of user_names with the number of movies thatthey have watched.
  1. Now adjust that query to include only a list of user_names thathave watched more than 5 distinct movies.
  1. Using the output from question number 2, create a column usingthe rank function to order the list by # of distinct movies watchedby user_name.

Expert Answer


Answer to Using SQL: I have 3 tables, “users”, “movies”, and “events” CREATE TABLE users (user_id INTEGER PRIMARY KEY, user_name T…

Leave a Comment

About

We are the best freelance writing portal. Looking for online writing, editing or proofreading jobs? We have plenty of writing assignments to handle.

Quick Links

Browse Solutions

Place Order

About Us

× How can I help you?