with
v1 as
(select
category_id
, film_id
, count(rental_id) as co
, rank() over(partition by category_id order by count(rental_id) desc) as ra
from film_category
join inventory using(film_id)
join rental using(inventory_id)
where year(rental_date) = 2005
group by category_id, film_id)
select
category_id
, group_concat(film_id)
from v1
where ra = 1
group by category_id