Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 (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
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