Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions

Question

5. Describe the relationship between history and identity.

Answered: 1 week ago