Solution Practice Set 3
Get the solution to the exercise of viewing the information queried from a database.
We'll cover the following...
Solution Practice Set 3
The database relationship model is reprinted below for reference.
Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/quiz.sh and wait for the MySQL prompt to start-up.
Question # 1
Write a query to display all those movie titles whose budget is greater than the average budget of all the movies.
This question also requires flexing MySQL’s aggregation capabilities. First we’ll write a query to calculate the average budget for all the films as follows:
SELECT AVG(BudgetInMillions)
FROM Movies;
Now, we can plug the above query as a sub-query and list all the movies whose budget was greater than the average budget across all movies.
SELECT Name
FROM Movies
WHERE BudgetInMillions > (SELECT AVG(BudgetInMillions)
FROM Movies);
Question # 2
Find all those actors who don’t have any digital media presence using a right join statement.
The Actors table has the ID column which is the same as the ActorID column of the DigitalAssets table. In a right join, the table on the right side of the join has all the rows included which don’t satisfy the join criteria. In this case, we want to include all the ...