with rental_dates as (
select
inventory_id,
return_date,
lead(rental_date) over (partition by inventory_id order by rental_date) next_rental_date
from rental
where return_date is not null
)
select avg(datediff(next_rental_date, return_date)) avg_days_between_rentals
from rental_dates
where next_rental_date is not null