0
votes

This is the problem I am trying to solve:

Refer to the film and inventory tables of the Sakila database. The tables in this lab have the same columns and data types but fewer rows.

Write a query that lists the titles of films with the fewest rows in the inventory table.

This query requires a subquery that computes the minimum of counts by film_id:

SELECT MIN(count_film_id) FROM ( SELECT COUNT(film_id) AS count_film_id FROM inventory GROUP BY film_id ) AS temp_table;

So far the code that I have is:

SELECT title FROM film INNER JOIN inventory ON inventory.film_id = film.film_id WHERE ( SELECT MIN(count_film_id) FROM ( SELECT COUNT(film_id) AS count_film_id FROM inventory GROUP BY film_id ) AS temp_table );

I have tried many different commands in the WHERE statement just before the subquery and I always end up with multiple repeats of the movie title instead of just two different titles. I'm very new to SQL so thanks for all the help.