Forum

Posted by Egor, July 15, 2022, 1:50 a.m.

44, less not-in-demand films

Hi, All

 

Just make sure once again, whether you apply any where conditions on top of left joined tables/ctes, and maybe it is better to keep them as join conditions and then use count for specific column to not count rows with null values.

This question is closed

Answers

Hi Egor,

Your code looks good, you are missing the films that are not in the inventory table, we assume that if a movie is not in stock, it's not in demand.

Thanks,

Leon

 

 

Hi, Leon

Thank you for your answer.  I am missing more than 200 films, but there are only 42 films that exist in film and don't exist in inventory. And they were included in my query. Sorry, if I don't see something evident. 

select count(film_id)
from film f
where not exists(
      select 1
      from inventory i
      where i.film_id = f.film_id
);

count
42

Egor, July 17, 2022, 8:46 p.m.
SQLPad user avatar

Leon (949)

July 17, 2022, 3:14 p.m.