1.关联两表 按tag,时间分组设置where过滤条件 取各日期点赞量及转发量最大值 2.在对1产生的结果进行窗口函数取7天内结果 3.在设置查询条件10-01-10-03 select tag, dt,sum_like_cnt_7d, max_retweet_cnt_7d from( select tag, dt, sum(likes_cnt) over(partition by tag order by dt rows 6 preceding) as sum_like_cnt_7d, max(retweets_cnt) over(partition by tag order by dt rows 6 preceding) as max_retweet_cnt_7d from( select tag, date_format(start_time, '%Y-%m-%d') as dt, sum(if_like) as likes_cnt, sum(if_retweet) as retweets_cnt from tb_user_video_log t join tb_video_info t1 on t.video_id = t1.video_id where datediff('2021-10-03', start_time)<9 group by tag,dt) a order by tag desc, dt asc) as b where date(dt) between '2021-10-01' and '2021-10-03'
点赞

相关推荐

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