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

近一个月发布的视频中热度最高的top3视频

https://www.nowcoder.com/practice/0226c7b2541c41e59c3b8aec588b09ff

with a as(select MAX(DATE(end_time)) rt
from tb_user_video_log t1 left join tb_video_info t2 on t1.video_id=t2.video_id
), 
b as(select t1.video_id,start_time,end_time,if_like	,if_retweet	,comment_id	,duration
from tb_user_video_log t1 left join tb_video_info t2 on t1.video_id=t2.video_id
where timestampdiff(day,date(release_time),(select rt from a))<=29),
c as(select video_id,AVG(IF(TIMESTAMPDIFF(SECOND, start_time, end_time)>=duration, 1, 0)) as comp_play_rate,SUM(if_like) as like_cnt,COUNT(comment_id) as comment_cnt,SUM(if_retweet) as retweet_cnt,MAX(DATE(end_time)) as recently_end_date
from b
group by video_id)
select video_id,round((100 * comp_play_rate + 5 * like_cnt + 3 * comment_cnt + 2 * retweet_cnt)/(timestampdiff(day,recently_end_date,(select rt from a))+1),0) hot
from c
order by hot desc
limit 3

全部评论

相关推荐

阿武同学:基本信息保留前面三行,其他的可以全部删掉,邮箱最重要的你没写,主修课程精简到8个以内,实习里面2/3/4都是水内容的,非要写的话建议两到三句话,项目经历排版优化下,自我评价缩到三行
点赞 评论 收藏
分享
09-14 17:23
门头沟学院
故事和酒66:所以说副业很重要,程序员干到40岁,再怎么也赚300万了,吃吃利息也够活下去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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