SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
select rental_date, return_date, lag(return_date) over(order by return_date, rental_date) as prv, sum(case when rental_date > lag(return_date) over(order by return_date, rental_date) then 1 else 0 end) over(order by return_date, rental_date) from rental where customer_id = 1 order by return_date, rental_date

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear