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

with basetable as(
select 
 u.video_id,
 u.if_like,
 u.if_retweet,
 u.comment_id,
 max(date(u.end_time))over(partition by u.video_id) as enddate,
 date(ct.current) as currenttime,
 date(v.release_time) as posttime,
 if(timestampdiff(second,u.start_time,u.end_time) >= v.duration,"完成","未完成") as tp
from tb_user_video_log u
left join tb_video_info v
on u.video_id = v.video_id
left join (
    select max(end_time) as current from tb_user_video_log
    ) ct on 1
)

select video_id,
       round((sum(if(tp="完成",1,0))/count(video_id)*100
       +sum(if_like)*5
       +count(comment_id)*3
       +sum(if_retweet)*2)
       /(datediff(currenttime,enddate)+1),0) as hot_index
from basetable
group by video_id,enddate,currenttime,posttime
having datediff(currenttime,posttime)<30
order by hot_index desc
limit 3



 




全部评论
点赞 回复 分享
发布于 01-12 13:43 北京

相关推荐

06-20 17:42
东华大学 Java
凉风落木楚山秋:要是在2015,你这简历还可以月入十万,可惜现在是2025,已经跟不上版本了
我的简历长这样
点赞 评论 收藏
分享
头顶尖尖的程序员:我是26届的不太懂,25届不应该是找的正式工作吗?为什么还在找实习?大四还实习的话是为了能转正的的岗位吗
点赞 评论 收藏
分享
07-02 10:44
门头沟学院 C++
码农索隆:太实诚了,告诉hr,你能实习至少6个月
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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