Forum

Posted by Bhumin, March 9, 2022, 3:33 p.m.

#40

Hello,
Can someone help me understand why this solution isn't right?
with most_rented as(
select film_id, count(*) as cnt
from rental
inner join inventory
on rental.inventory_id = inventory.inventory_id
where extract(year_month from rental_ts) = 202006
group by film_id
order by cnt desc
limit 2)
select film_id, title from film where film_id in (select film_id from most_rented)
This question is closed

Answers

Hi Bhumin,
Your query looks correct, and should work in MySQL, but the year_month syntax is not supported for postgres, was it because you ran it in Postgres?
Thanks,
Leon
SQLPad user avatar

Leon (949)

March 9, 2022, 8:47 p.m.