I am trying to develop my SQL (MySQL) capabilities in the Sakila database. I have questions on the following question: What is the average movie rental time per category and per year?
Here's my query so far:
select avg(r.return_date - r.rental_date) as avgDate, c.name
from
rental r, category c
inner join inventory i
on i.inventory_id = r.inventory_id
inner join film f
on f.film_id=i.film_id
group by c.name
order by avgDate desc;
The error is as follows:
Error Code: 1054. Unknown column 'r.inventory_id' in 'on clause'.
I know the part of the year is still missing, but I am trying to solve this problem. Someone can help me?
Thanks!!