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

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

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

with
    t1 as (
        select
            b.tag tag,
            substr(a.start_time, 1, 10) start_time,
            sum(a.if_like) likes,
            sum(a.if_retweet) retweet
        from
            tb_user_video_log a
            left join tb_video_info b 
            on a.video_id =b.video_id
        group by
            b.tag,
            substr(a.start_time, 1, 10)
    )  
select *
from (
select
    c.tag,
    substr(c.start_time, 1, 10) dt,
#    c.likes, c.retweet,
    sum(c.likes) over (
        partition by
            c.tag
        order by substr(c.start_time, 1, 10) ROWS BETWEEN 6 PRECEDING AND CURRENT ROW
    ) sum_like_cnt_7d,
    max(c.retweet) over (
        partition by
            c.tag
        order by
            substr(c.start_time, 1, 10) ROWS BETWEEN 6 PRECEDING
            AND CURRENT ROW
    ) max_retweet_cnt_7d
from
    (select * from t1  ) c
    order by c.tag desc,dt asc
)d 
where
    substr(d.dt, 1, 10) >= '2021-10-01'
    and substr(d.dt, 1, 10) <= '2021-10-03'

全部评论

相关推荐

01-07 07:54
已编辑
门头沟学院 前端工程师
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务