Question: For this homework,you will be using the sakila database Task 1 (20 points): Rewrite the following query as an subquery against rental table using the

 For this homework,you will be using the sakila database Task 1

For this homework,you will be using the sakila database Task 1 (20 points): Rewrite the following query as an 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 sakilapayment p ON ccus tomerid- p.customerid JOIN sakila.rental r ON p.rentalid rrentalid wHERE rental-date BETWEEN-2005-05-25' AND '2005-05-26' GROUP BY firstname, 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 sakilacustomer c JOIN sakila.payment p ON scustomerid-p.customerid GROUP BYast.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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!