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

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

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

with t as(
    select 
        t1.video_id,
        avg(case when timestampdiff(second,start_time,end_time)>=duration then 1
            else 0 end ) as a,
        sum(if_like) as b,
        count(comment_id) as c,
        sum(if_retweet) as d,
        DATEDIFF((select date(max(end_time)) from tb_user_video_log),date(max(end_time))) as e
    from tb_user_video_log t1
    left join tb_video_info t2
        on t1.video_id=t2.video_id
    where datediff ((select date(max(end_time)) from tb_user_video_log),date(release_time))<=29
    group by video_id
)
select video_id,round((100*a+5*b+3*c+2*d)/(e+1)) as hot_index
from t
order by hot_index desc
limit 3

全部评论

相关推荐

牛客41406533...:回答他在课上学,一辈子待在学校的老教授用三十年前的祖传PPT一字一句的讲解,使用谭浩强红皮书作为教材在devc++里面敲出a+++++a的瞬间爆出114514个编译错误来学这样才显得专业
点赞 评论 收藏
分享
09-26 19:45
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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