题解 | 统计创作者

统计创作者

https://www.nowcoder.com/practice/5f0155102879494c8707f749156f9af3

select
    a.author_id, a.author_name,
    count(p.post_id) as posts_30d,
    sum(p.like_cnt) as likes_30d,
    round(sum(p.like_cnt) / nullif(count(p.post_id), 0), 2) as avg_likes_30d
from
    author a join post p on a.author_id = p.author_id
where
    p.publish_ts >= 
        (select date_sub(max(publish_ts), interval 30 day) from post)
group by 
    a.author_id, a.author_name
order by
    likes_30d desc, posts_30d desc, a.author_id asc
limit
    0, 5;

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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