We have following relationmovie_streaming(id,date,movie,director,number_of_streams)1) Find the total number of streams by date.2) Find the total number of streams by date and director.3) Find the total number of streams by date and director. Show only dates with a totalnumber of streams above 740
Question
We have following relationmovie_streaming(id,date,movie,director,number_of_streams)1) Find the total number of streams by date.2) Find the total number of streams by date and director.3) Find the total number of streams by date and director. Show only dates with a totalnumber of streams above 740
Solution
- To find the total number of streams by date, you can use the SQL
GROUP BYclause. Here is the SQL query:
SELECT date, SUM(number_of_streams)
FROM movie_streaming
GROUP BY date;
- To find the total number of streams by date and director, you can extend the previous query to include the director in the
GROUP BYclause:
SELECT date, director, SUM(number_of_streams)
FROM movie_streaming
GROUP BY date, director;
- To find the total number of streams by date and director, but only show dates with a total number of streams above 740, you can add a
HAVINGclause to the previous query:
SELECT date, director, SUM(number_of_streams)
FROM movie_streaming
GROUP BY date, director
HAVING SUM(number_of_streams) > 740;
The HAVING clause is used in SQL to filter the results of a GROUP BY clause, similar to how the WHERE clause is used to filter the results of a SELECT statement.
Similar Questions
Directions: The question or incomplete statement below is followed by four suggested answers or completions. Select the one that is best in each case.A video-streaming service maintains a database of information about its customers and the videos they have watched.The program below analyzes the data in the database and compares the number of viewers of science fiction videos to the number of viewers of videos of other genres. It uses the procedure , which returns the number of unique users who viewed videos of a given category in the past year. The procedure takes approximately 1 hour to return a result, regardless of the number of videos of the given genre. All other operations happen nearly instantaneously. Which of the following best approximates the amount of time it takes the program to execute?Responses1 hour1 hour2 hours2 hours4 hours4 hours5 hours
We have following relationorders(order_id,customer_id,order_date,amount)1) Find out the number of orders for each customer by customer_id.2) Find out the total amount by order_id and order_date.3) Find out the number of orders for each customer by customer_id. Show onlycustomer_id with number of orders above 5
Let a table Student has 10 records and Stream has 3 records, then how many rows we will get by using below query:Select * from Student, StreamA3B10C13D30
Lena plans to watch 2 movies each month. Write an equation to represent the total number of movies n that she will watch in m months.
List titles of films with 10 or more actors playing the act. Sort the output on descending order of actors per film.will the below query will provide you the correct result SELECT title as Film_Name, count(actor_id) as Total_ActorsFROM filmINNER JOINfilm_actorONfilm.film_id=film_actor.film_idGroup by film.film_idhaving Total_Actors > 9ORDER BYTotal_Actors DESC, titlea.Trueb.False
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.