题解 | 每类视频近一个月的转发量/率

每类视频近一个月的转发量/率

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

with data_bounds as (
    select
        date(max(end_time)) as max_date,
        date_sub(date(max(end_time)),interval 29 day) as min_date
    from
        tb_user_video_log
)
select
    tt.tag,
    sum(tg.if_retweet) as retweet_cnt,
    round(sum(tg.if_retweet) / count(tg.start_time),3) as retweet_rate
from
    tb_user_video_log tg
join
    tb_video_info tt on tg.video_id = tt.video_id
cross join data_bounds d
where 
    date(tg.end_time) between d.min_date and d.max_date
group by 
    tt.tag
order by 
    retweet_rate desc

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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