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

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

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-01 08:48
门头沟学院 C++
伤心的候选人在吵架:佬你不要的,能不能拿户口本证明过户给我。。球球了
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务