Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find the first_name, last_name and total_combined_film_length of Sci-Fi films for every actor. That is the result should list the names of all of the actors(even

Find the first_name, last_name and total_combined_film_length of Sci-Fi films for every actor.

That is the result should list the names of all of the actors(even if an actor has not been in any Sci-Fi films) and the total length of Sci-Fi films they have been in.

Look at the category table to figure out how to filter data for Sci-Fi films.

Order your results by the actor_id in descending order.

I have the following results. But i can't figure out how to change my Null values to 0 values?

Here is my code:

-- Put query for Q3 here SELECT act.actor_id, act.first_name,act.last_name, sci_fi.sum as total_combined_film_length FROM actor act LEFT JOIN (SELECT act.actor_id AS actor_id, SUM(f.length) AS sum FROM actor act INNER JOIN film_actor fa ON act.actor_id=fa.actor_id INNER JOIN film f ON fa.film_id=f.film_id INNER JOIN film_category fc ON f.film_id=fc.film_id INNER JOIN category cate ON fc.category_id=cate.category_id WHERE cate.name='Sci-Fi' GROUP BY act.actor_id ORDER BY sum ASC) AS sci_fi ON act.actor_id=sci_fi.actor_id ORDER BY act.actor_id DESC;

Here is some my output:

YOUR CODE'S OUTPUT

actor_id first_name last_name total_combined_film_length 200 THORA TEMPLE 287 199 JULIA FAWCETT NULL 198 MARY KEITEL 314 197 REESE WEST 190 196 BELA WALKEN 59 195 JAYNE SILVERSTONE 263 194 MERYL ALLEN NULL 193 BURT TEMPLE 113 192 JOHN SUVARI 392 191 GREGORY GOODING 277 190 AUDREY BAILEY 211 189 CUBA BIRCH NULL

Here is the expected code:

THE CORRECT OUTPUT OF THE TEST CASE

actor_id first_name last_name total_combined_film_length 200 THORA TEMPLE 287 199 JULIA FAWCETT 0 198 MARY KEITEL 314 197 REESE WEST 190 196 BELA WALKEN 59 195 JAYNE SILVERSTONE 263 194 MERYL ALLEN 0 193 BURT TEMPLE 113 192 JOHN SUVARI 392 191 GREGORY GOODING 277 190 AUDREY BAILEY 211 189 CUBA BIRCH 0

The NULL values should be 0, any guidance is appreciated. Thank you

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

Step: 3

blur-text-image

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

Database Machine Performance Modeling Methodologies And Evaluation Strategies Lncs 257

Authors: Francesca Cesarini ,Silvio Salza

1st Edition

3540179429, 978-3540179429

More Books

Students also viewed these Databases questions