Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help with code as I working a problem in SQL. The question ask Find the best collaborators. Get the 5 cast members with

I need help with code as I working a problem in SQL. The question ask Find the best collaborators. Get the 5 cast members with the highest average scores from the good_collaboration view, and call this score the collaboration_score. This score is the average of the average_movie_score corresponding to each cast member, including actors in cast_member_id1 as well as cast_member_id2. Format all decimals to two places using printf(). Sort your output by collaboration_score in descending order, then by cast_name alphabetically.

Output format (cast_id,cast_name,collaboration_score): 2,Mark Hamil,99.32 1920,Winoa Ryder,88.32

so the inner part is based on a union you have to first union up good_collaboration the cast id1 and score - unioned up with cast id2 and score

The code below provides data but not in the correct order.

def part_gi(self,connection):

############### EDIT SQL STATEMENT ###################################

part_g_i_sql ="select cast_id,cast_name, avg(score) collaboration_score from movies, movie_cast where movies.id=movie_cast.movie_id group by cast_id, cast_name order by collaboration_score desc, cast_name asc limit 5"

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 Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions