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

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

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

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

就是这么简单!

#sql##sql练习日常#
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-09 12:20
点赞 评论 收藏
分享
半解316:内容充实,细节需要修改一下。 1,整体压缩为一页。所有内容顶格。 2,项目描述删除,直接写个人工作量 修改完之后还需要建议,可以私聊
点赞 评论 收藏
分享
认真搞学习:这么良心的老板真少见
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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