SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
with d as ( select inventory_id, return_date, lag(rental_date) over (partition by film_id order by rental_date desc) next_rental_date from rental join inventory using (inventory_id) where return_date is not null ) select avg(datediff(next_rental_date, return_date)) avg_days_between_rentals from d where next_rental_date is not null

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear