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

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

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

with
    t4 as (
        select
            tag,
            dt,
            sum(if_like) as like_cnt,
            sum(if_retweet) as retweet_cnt
        from
            (
                select
                    t1.video_id,
                    date_format (start_time, '%Y-%m-%d') as dt,
                    if_like,
                    if_retweet,
                    tag
                from
                    tb_user_video_log t1
                    left join tb_video_info t2 using (video_id)
                where
                    date_format (start_time, '%Y-%m-%d') between '2021-09-25' and '2021-10-03'
            ) t3
        group by
            tag,
            dt
    )
select
    *
from
    (
        select
            tag,
            dt,
            sum(like_cnt) over (
                partition by
                    tag
                order by
                    dt rows 6 preceding
            ) as sum_like_cnt_7d,
            max(retweet_cnt) over (
                partition by
                    tag
                order by
                    dt rows 6 preceding
            ) as max_retweet_cnt_7d
        from
            t4
    ) t5
where
    dt like '%2021-10%'
order by
    tag desc,
    dt

全部评论

相关推荐

11-01 08:48
门头沟学院 C++
伤心的候选人在吵架:佬你不要的,能不能拿户口本证明过户给我。。球球了
点赞 评论 收藏
分享
我是小红是我:学校换成中南
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务