题解 | 每篇文章同一时刻最大在看人数

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

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

select artical_id,max(num) max_uv from(
select artical_id,sum(sign)over(partition by artical_id order by time,sign desc) num
from(
select artical_id,in_time as time,1 as sign
from tb_user_log
where artical_id != 0

union all

select artical_id,out_time as time,-1 as sign
from tb_user_log
where artical_id != 0) as t1) as t2
group by artical_id
order by max_uv desc

全部评论

相关推荐

求offer的大角牛:不吃香菜
点赞 评论 收藏
分享
点赞 评论 收藏
分享
07-03 16:02
门头沟学院 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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