Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The Silika Databasecan also be downloaded at https://dev.mysql.com/doc/index-other.html For this homework, you will be using the sakila database. Task 1 (20 points): Rewrite the following
The Silika Databasecan also be downloaded at https://dev.mysql.com/doc/index-other.html
For this homework, you will be using the sakila database. Task 1 (20 points): Rewrite the following query as a subquery against rental table using the IN predicate. In other words, keep the JOIN between customer and payment and create a list of appropriate entries for the IN predicate from the rental table SELECT first_name, last_name, SUM (amount) AS totalSpent FROM sakila.customer c JOIN sakila.payment p ON c.cus tomer_id - p.customer id JOIN sakila.rental r ON p.rental id- r.rental_id WHERE rental_date BETWEEN '2005-05-25' AND '2005-05-26' GROUP BY first name, last_name; Task 2 (20 points): Show a list of all actors who played in films rated as "PG". Use a subquery against films table as part of your query to get the results - do NOT use a JOIN between actors, film_actors, and film. Task 3 (20 points): Rewrite the following query so that SUM(amount) is calculated as a subquery. In other words, select data only from the customer table and for each record from the customer table calculate the sum as a subquery from the payment table. SELECT first name, last_name, SUM (amount) AS totalSpent FROM sakila.customer c JOIN sakila.payment p ON c.customer_id- p.customer_id GROUP BY last name, first_name; Task 4 (20 points) Explain how a subquery works and write an example. Task 5 (20 points) Explain how a correlated subquery and write an example. mLICSMALLIN reme VARCHARY23 phore VARCHARD Customer relatod dats desition TEXT Movio database ast name VARCH.. nicer _but slower f im Jist fim in stock sim not n.tock im.not n.sto actor into nventbry held by.au rewasreport ales by tore taf ist customerlist Special wow on certain data uaed for appraisalsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started