SQL163面试真题

统计每篇文章同一时刻最大在看人数

select artical_id, max(uv)max_uv from

(

    select artical_id, sum(tag)over(partition by artical_id order by time, tag DESC)uv from

    (  

        select artical_id, in_time as time, 1 as tag from tb_user_log union all

        select artical_id, out_time as time, -1 as tag from tb_user_log

    )a

)b

where b.artical_id != 0

group by b.artical_id

order by max_uv DESC

全部评论

相关推荐

2025-11-15 14:35
南京邮电大学 Java
程序员牛肉:你这简历有啥值得拷打的?在牛客你这种简历一抓一大把,也就是个人信息不一样而已。 关键要去找亮点,亮点啊,整个简历都跟流水线生产出来的一样。
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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