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

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

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

select video_id,
round((100*a+5*b+3*c+2*d)/(e+1)) hot_index
from (
select tbu.video_id,
avg(if(timestampdiff(second,start_time,end_time)>=duration,1,0)) a,
sum(if_like) b,
count(comment_id) c,
sum(if_retweet) d,
datediff(date((select max(end_time) from tb_user_video_log)),max(date(end_time))) e
from tb_user_video_log tbu left join tb_video_info tbi on tbu.video_id=tbi.video_id 
where datediff(date((select max(end_time) from tb_user_video_log)),date(release_time))<30 
group by tbu.video_id) as t1
order by hot_index desc
limit 3
;

参考评论区的大佬的改了datediff(date((select max(end_time) from tb_user_video_log)),max(date(end_time)))这条,但实际上我还是不理解为什么里面date((select max(end_time) from tb_user_video_log))这部分date()为什么必须写成两层括号才行,一层就报错,还请走过路过的大佬们赐教,谢谢各位

全部评论

相关推荐

huo12138:校友,传奇耐面王
点赞 评论 收藏
分享
StephenZ_:我9月份找的第一段实习也是遇到这种骗子公司了,问他后端有多少人和我说7个正职,进去一看只有一个后端剩下的都是产品前端算法(没错甚至还有算法)。还是某制造业中大厂,我离职的时候还阴阳怪气我
点赞 评论 收藏
分享
11-03 18:50
门头沟学院 Java
迷茫的大四🐶:问就是马上到,一周五天,6个月以上,全国可飞
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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