Posted by Prasad, Feb. 15, 2022, 12:49 p.m.
Question 69
How my below MySQL solution is wrong for Question #69
select count(customer_id)
from
(select customer_id, day(return_ts) day,
(lead(day(return_ts))over(partition by customer_id order by day(return_ts))-
day(return_ts))diff
from rental
where month(return_ts) =5
and day(return_ts)>=24
and day(return_ts) <=31) as inn
where diff is not null;
and diff<=1
select count(customer_id)
from
(select customer_id, day(return_ts) day,
(lead(day(return_ts))over(partition by customer_id order by day(return_ts))-
day(return_ts))diff
from rental
where month(return_ts) =5
and day(return_ts)>=24
and day(return_ts) <=31) as inn
where diff is not null;
and diff<=1