with sov as
(select film_id, count(film_id) store_1_count
from inventory where store_id=1
group by film_id),
mov as (select film_id, count(film_id)
store_2_count
from inventory where store_id=2
group by film_id),
gov as (select film_id, count(film_id) total_count
from inventory group by film_id)
select sov.film_id, store_1_count,
store_2_count, total_count from sov
join mov on sov.film_id=mov.film_id
join gov on mov.film_id=sov.film_id