法2需要修改时间条件的位置: with t1 as( select uid, date(in_time) as dt from tb_user_log union select uid, date(out_time) as dt from tb_user_log), t2 as (select uid, dt, min(dt) over(partition by uid) as min_time, lead(dt, 1) over(partition by uid order by dt) as next_time from t1) select dt, round(sum(case when dt = min_time and datediff(next_time, dt) = 1 then 1 else 0 end) / sum(case when dt = min_time then 1 else 0 end), 2) as uv_left_rate from t2 where date_format(min_time, '%Y%m') = 202111 group by dt having uv_left_rate is not null order by dt
点赞

相关推荐

看起来名字可以很长:笑死 我暑期实习阿里云的意向也被 qq 邮箱放在垃圾箱了
点赞 评论 收藏
分享
10-30 19:23
已编辑
山东大学(威海) C++
牛至超人:其实简历是不需要事无巨细的写的,让对方知道你有这段经历就行了,最重要的是面试的时候讲细讲明白
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务