题解 | 被重复观看次数最多的3个视频

被重复观看次数最多的3个视频

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

select
    t.cid,
    sum(t.pv) as pv,
    row_number() over(order by sum(t.pv) desc,c.release_date desc) as rk
from
    (select
        p.cid,
        count(p.uid) as pv
    from 
        play_record_tb p
    group by 
        p.cid,p.uid
    having count(p.uid)>1
    ) t
left join 
    course_info_tb c 
on 
    t.cid=c.cid
group by   
    t.cid,t.pv,c.release_date
order by 
    row_number() over(order by sum(t.pv) desc,c.release_date desc) asc 
limit 3

全部评论

相关推荐

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

创作者周榜

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