题解 | #近一个月发布的视频中热度最高的top3视频#

拆解重组是解答所有复杂题目的核心,以不变应万变

select video_id,round((100*(sum(play)/count(play))+5*sum(if_like)+3*sum(if(comment_id is null,0,1))+2*sum(if_retweet))/(avg(no_play)+1),0) hot_index from  
(select video_id,case when timestampdiff(second,start_time,end_time) >= duration then 1 else 0 end play,if_like,comment_id,if_retweet,datediff(max(date(end_time))over(),max(date(end_time))over(partition by video_id)) no_play from tb_user_video_log join tb_video_info using(video_id)
where date(release_time) >= (select date_sub(max(date(end_time)),interval 29 dayfrom tb_user_video_log)) t1
group by video_id
order by hot_index desc
limit 3

全部评论

相关推荐

12-19 16:52
门头沟学院
点赞 评论 收藏
分享
11-03 13:18
门头沟学院 Java
包行:平时怎么刷算法题的哇,字节的手撕听说都很难
字节跳动工作体验
点赞 评论 收藏
分享
明天不下雨了:这个项目 这个简历 这个模板 莫不是一个开源的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务