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

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

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

select
b.video_id,
round((100*(sum(b.if_ok)/count(1))+5*sum(b.if_like)+3*count(b.comment_id)
+2*sum(b.if_retweet))/(min(b.near_day)+1)) as hot_index
from
(
select
tuvl.video_id,
if(timestampdiff(second,tuvl.start_time,tuvl.end_time)>=a.duration,1,0) if_ok,
tuvl.if_like,
tuvl.if_retweet,
tuvl.comment_id,
timestampdiff(day,date(tuvl.end_time),
(select date(max(end_time)) from tb_user_video_log)) near_day
from tb_user_video_log tuvl 
inner join
(
select 
video_id,
duration
from tb_video_info 
where timestampdiff(day,date(release_time),
(select date(max(end_time)) from tb_user_video_log))<=29
) a on tuvl.video_id=a.video_id
) b
group by b.video_id
order by hot_index desc
limit 3

全部评论

相关推荐

有工作后先养猫:太好了,是超时空战警,我们有救了😋
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务