题解 | #平均播放进度大于60%的视频类别#

每个创作者每月的涨粉率及截止当前的总粉丝量

http://www.nowcoder.com/practice/d337c95650f640cca29c85201aecff84

SELECT
    author,
    SUBSTR(start_time,1,7) AS month,
    ROUND(SUM(CASE
    WHEN if_follow=2 THEN -1
    WHEN if_follow=0 THEN 0
    WHEN if_follow=1 THEN 1
    END )/COUNT(video_id),3) AS fans_growth_rate,
    SUM(
    SUM(CASE
    WHEN if_follow=2 THEN -1
    WHEN if_follow=0 THEN 0
    WHEN if_follow=1 THEN 1
    END)) OVER(PARTITION BY author ORDER BY SUBSTR(start_time,1,7)) AS total_fans
FROM tb_video_info info
JOIN tb_user_video_log log USING(video_id)
WHERE YEAR(end_time)=2021
GROUP BY author,SUBSTR(start_time,1,7)
ORDER BY author,total_fans
全部评论

相关推荐

无情咸鱼王的秋招日记之薛定谔的Offer:好拒信,偷了,希望有机会用到
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务