不用子查询,一次就可以。select t2.video_id, round((100*avg(if(timestampdiff(second,start_time,end_time)>=duration,1,0))+5*sum(if_like)+3*count(comment_id)+2*sum(if_retweet))/(datediff(cur_time,max(end_time))+1),0) as hot_index from tb_user_video_log as t1 join tb_video_info as t2 using(video_id) join (select max(end_time) as cur_time from tb_user_video_log) as t3 on 1 group by 1,release_time,cur_time having(datediff(cur_time,release_time)<30) order by 2 desc limit 3
1

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务