题解 | #对比一周的播放完成率变化#

对比一周的播放完成率变化

https://www.nowcoder.com/practice/47852dbdf412481198597eaa1505ecd6

with cte as (
select uid,a.vid,time_len,weekday(start_time)+1 as weekth,
           unix_timestamp(end_time)-unix_timestamp(start_time) as seconds
from user_play_log_tb a left join video_info_tb b on a.vid=b.vid ),
cte1 as (
select weekth, avg(if(seconds<time_len,seconds/time_len,1)) as play_ratio
from cte
group by weekth
order by weekth
)
select weekth,
concat(round((lead(play_ratio,1,(select play_ratio from cte1 where weekth=1))over(order by weekth)-play_ratio)/play_ratio*100,1),'%') as play_ratio_delta
from cte1

两个率不应该这么减

全部评论

相关推荐

不愿透露姓名的神秘牛友
11-20 19:57
已编辑
某大厂 golang工程师 23.0k*16.0, 2k房补,年终大概率能拿到
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务