Forum

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

Answers

Hey, Gurpreet, you've got the right answer, but your label (first column) 'in_stock' has an extra '_', replace it with an empty space => ('in stock') will fix it.
SQLPad user avatar

Leon (949)

Nov. 1, 2021, 5:37 p.m.