题解 | #国庆期间每类视频点赞量和转发量#
国庆期间每类视频点赞量和转发量
https://www.nowcoder.com/practice/f90ce4ee521f400db741486209914a11
select e.* from (select d.tag,d.month,sum(d.all_like) over(partition by d.tag order by d.month desc rows between current row and 6 following )sum_like_cnt_7d
,max(d.all_retweet) over(partition by d.tag order by d.month desc rows between current row and 6 following )max_retweet_cnt_7d
from
(select c.tag,c.month,sum(c.if_like)all_like,sum(c.if_retweet) all_retweet
from
(select a.uid,a.video_id,a.start_time,a.end_time,DATE_FORMAT(end_time,'%Y-%m-%d')month,a.if_like,a.if_retweet,b.tag,b.author from tb_user_video_log a join tb_video_info b on a.video_id=b.video_id)c
group by c.tag,c.month)d)e
where e.month between'2021-10-01'
and '2021-10-03' order by e.tag desc,e.month ;