Posted by gurpreet, Oct. 29, 2021, 7:48 p.m.
SQL#42
I have used the following code and getting the correct results but even then it is not being accepted upon submission.
I get an error message saying Incorrect result. Can someone have a look and tell me what could be the reason for error?
select stock,
count(*) as count
from
(
SELECT a.film_id,
case when count(b.inventory_id) > 0 then 'in_stock'
else 'not in stock'
end as stock
FROM film a left join inventory b
on a.film_id = b.film_id
group by a.film_id
) c
group by stock
I get an error message saying Incorrect result. Can someone have a look and tell me what could be the reason for error?
select stock,
count(*) as count
from
(
SELECT a.film_id,
case when count(b.inventory_id) > 0 then 'in_stock'
else 'not in stock'
end as stock
FROM film a left join inventory b
on a.film_id = b.film_id
group by a.film_id
) c
group by stock