SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
with t as ( select row_number() over(order by return_date, rental_date) as n, rental_date as start_date, return_date as end_date, lag(return_date) over(order by return_date, rental_date) as prew_rent from rental where customer_id = 1 ) select *, sum(case when start_date > prew_rent then 1 else 0 end) over () as period from t

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear