Forum

Posted by AR, Dec. 2, 2021, 6:58 p.m.

Question 32 Unpopular Movies

Question 32 asks to Write a query to return the number of films with no rentals in Feb 2020.
I took a look at the solution and understand the logic. The logic I used approached it from the opposite angle. I filtered to inventory which wasn't rented in Feb 2020 and try to count all the distinct film ids. Why does the following approach not work?
select count( distinct film_id)
from inventory
where inventory_id in (select inventory_id
from rental
where date(rental_ts) < '2020-02-01'
or date(rental_ts) > '2020-02-29')

Answers

Hey AR,
Great question, that's actually the tricky part (designed to be like a real-world situation).
Hint: imagine you are the movie DVD store owner, you may not need all of the films from the catalog to be in your store's inventory.
Hope this helps,
Leon
SQLPad user avatar

Leon (949)

Dec. 3, 2021, 12:50 p.m.