题解 | 牛客每个人最近的登录日期(三)
牛客每个人最近的登录日期(三)
https://www.nowcoder.com/practice/16d41af206cd4066a06a3a0aa585ad3d
select round(sum(cnt_1)/sum(cnt_all), 3) as p from( select count(distinct t1.user_id) as cnt_all, if(sum(t2.date is not null and t1.date is not null)>=1, 1, 0) as cnt_1 from login as t1 left join login as t2 on t1.user_id = t2.user_id and t2.date = date_add(t1.date, interval 1 day) group by t1.user_id) as t3 # 用join

