SQL exercises on movie Database: Find all the movies with title, year, date of release, duration, and name of the director which released before 1st January 1989, and sort the result in descending order on release date
SQL movie Database: Join Exercise-9 with Solution
9. Write a query in SQL to list all the movies with title, year, date of release, movie duration, and first and last name of the director which released before 1st January 1989, and sort the result set according to release date from highest date to lowest.
Sample table: movie
Sample table: director
Sample table: movie_direction
Sample Solution:
SELECT movie.mov_title, mov_year, mov_dt_rel,
mov_time,dir_fname, dir_lname
FROM movie
JOIN movie_direction
ON movie.mov_id = movie_direction.mov_id
JOIN director
ON movie_direction.dir_id=director.dir_id
WHERE mov_dt_rel <'01/01/1989'
ORDER BY mov_dt_rel desc;
Sample Output:
mov_title | mov_year | mov_dt_rel | mov_time | dir_fname | dir_lname ----------------------------------------------------+----------+------------+----------+----------------------+---------------------- Aliens | 1986 | 1986-08-29 | 137 | James | Cameron Amadeus | 1984 | 1985-01-07 | 160 | Milos | Forman Deliverance | 1972 | 1982-10-05 | 109 | John | Boorman Blade Runner | 1982 | 1982-09-09 | 117 | Ridley | Scott The Deer Hunter | 1978 | 1979-03-08 | 183 | Michael | Cimino Annie Hall | 1977 | 1977-04-20 | 93 | Woody | Allen Chinatown | 1974 | 1974-08-09 | 130 | Roman | Polanski Lawrence of Arabia | 1962 | 1962-12-11 | 216 | David | Lean The Innocents | 1961 | 1962-02-19 | 100 | Jack | Clayton Vertigo | 1958 | 1958-08-24 | 128 | Alfred | Hitchcock (10 rows)
Practice Online

Query Visualization:
Duration:

Rows:

Cost:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a query in SQL to list all the movies with year, genres, and name of the director.
Next: Write a query in SQL to compute a report which contain the genres of those movies with their average time and number of movies for each genres.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- React - JavaScript Library
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework