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

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

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

with
    temp as (
	    #根据最近的天数过滤数据
        select
            video_id,
            if_retweet
        from
            tb_user_video_log,
			# 求最近的天数
            (
                select
                    end_time max_end_time
                from
                    tb_user_video_log
                order by
                    end_time desc
                limit
                    1
            ) as max_time
        where
            end_time >= date_sub(max_end_time, interval 30 day)
            and end_time <= max_end_time
    )
#联表求结果
select
    tag,
    sum(if_retweet) retweet_cut,
    round(sum(if_retweet) / count(*), 3) retweet_cut
from
    temp
    join tb_video_info using (video_id)
group by
    tag
order by
    retweet_cut desc

全部评论

相关推荐

敢逐云霄志:你打招呼语怎么能这么长,hr都没看下去的欲望,简明扼要说重点,就读于某某学校某某专业,26届应届毕业生,学信网可查,先后在某某公司实习过(如有),然后做过什么项目,想找一份什么样的工作,可实习几个月以上,期待您的回复。
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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