题解 | #国庆期间每类视频点赞量和转发量#

国庆期间每类视频点赞量和转发量

https://www.nowcoder.com/practice/f90ce4ee521f400db741486209914a11

with tmp as (select 
    tvi.tag as tag,
    date_format(tuvl.start_time,'%Y-%m-%d') as dt,
    sum(sum(if_like)) over (partition by tag order by date_format(tuvl.start_time,'%Y-%m-%d') rows 6 preceding) as sum_like_cnt_7d,
    max(sum(if_retweet)) over(partition by tag order by date_format(tuvl.start_time,'%Y-%m-%d') rows 6 preceding) as max_retweet_cnt_7d
from tb_user_video_log as tuvl
left join tb_video_info as tvi
on tuvl.video_id = tvi.video_id 
where date_format(tuvl.start_time,'%Y-%m-%d') between '2021-09-24' and '2021-10-03'
group by tvi.tag, date_format(tuvl.start_time,'%Y-%m-%d')
)
select * from tmp 
where dt between '2021-10-01' and '2021-10-03'
order by tag desc, dt asc

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 13:05
TMD找工作本来就烦,这东西什么素质啊😡
Beeee0927:hr是超雄了,不过也是有道理的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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