SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
select avg(t2.avg_f) from ( select t1.film_id, t1.store_id, avg(t1.diff) as avg_f from ( select i.film_id, i.store_id, datediff(r.return_date, lead(r.rental_date) over(partition by i.film_id, i.store_id order by r.rental_date asc)) as diff from rental r left join inventory i on r.inventory_id = i.inventory_id order by i.film_id asc ) as t1 group by t1.film_id, t1.store_id ) as t2

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear