Write a SQL Query to find those lowest duration movies along with the year, director’s name(first and last name combined), actor’s name(first and last name combined) and his/her role in that production.
Output Schema:
movie_title,movie_year,director_name,actor_name,role
NOTE:
- Output column name has to match the given output schema.
- Any name is the concatenation(without any delimiter) of first and last name if present
- (E.g. if director_first_name is ‘Alfred’ and director_last_name is ‘Hitchcock’ then director_name is ‘AlfredHitchcock’)
Example Output:
movie_title,movie_year,director_name,actor_name,role
Vertigo,1958,AlfredHitchcock,JamesStewart,JohnFerguson
Schema Design:
Solutions:
- SELECT movie_title, movie_year, CONCAT(TRIM(director_first_name), TRIM(director_last_name)) as director_name,
- CONCAT(TRIM(actor_first_name), TRIM(actor_last_name)) as actor_name, role
- FROM movies
- NATURAL JOIN movies_directors
- NATURAL JOIN movies_cast
- NATURAL JOIN directors
- NATURAL JOIN actors
- WHERE movie_time=(SELECT MIN(movie_time) FROM movies);
Comments
Post a Comment