w3resource
SQL exercises

SQL exercises on movie Database: Find the reviewer name, movie title, and number of stars for those movies which rating is the lowest one

SQL movie Database: Subquery Exercise-14 with Solution

14. Write a query in SQL to return the reviewer name, movie title, and number of stars for those movies which rating is the lowest one.

Sample table : reviewer


Sample table: rating


Sample table: movie


Sample Solution:

SELECT reviewer.rev_name, movie.mov_title, rating.rev_stars
FROM reviewer, movie, rating
WHERE rating.rev_stars = (
SELECT MIN(rating.rev_stars)
FROM rating
)
AND rating.rev_id = reviewer.rev_id
AND rating.mov_id = movie.mov_id;

Sample Output:

            rev_name            |                     mov_title                      | rev_stars
--------------------------------+----------------------------------------------------+-----------
 Paul Monks                     | Boogie Nights                                      |      3.00
(1 row)

Practice Online


Movie database model

Query Visualization:

Duration:

Query visualization of Find the reviewer name, movie title, and number of stars for those movies which rating is the lowest one - Duration

Rows:

Query visualization of Find the reviewer name, movie title, and number of stars for those movies which rating is the lowest one - Rows

Cost:

Query visualization of Find the reviewer name, movie title, and number of stars for those movies which rating is the lowest one - Cost

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to find the titles of all movies which have been reviewed by anybody except by Paul Monks.
Next: Write a query in SQL to find the titles of all movies directed by James Cameron.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming