SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
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 inventory_id in (6,9) ) SELECT inventory_id,return_date,next_rental_date,(datediff(next_rental_date,return_date)) FROM rental_dates /* select avg(datediff(next_rental_date, return_date)) avg_days_between_rentals from rental_dates where next_rental_date is not null*/

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear