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

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

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

with a3 as(
with a2 as(
with a1 as (select artical_id,in_time dt,1 cnt from tb_user_log where artical_id != 0
union all
select artical_id,out_time dt,-1 cnt from tb_user_log
where artical_id != 0
order by dt,cnt desc)
select artical_id,cnt,row_number()over(partition by artical_id order by dt) ranking
from a1)
select artical_id,sum(cnt)over(partition by artical_id order by ranking) sum_cnt
from a2)
select artical_id,max(sum_cnt) max_uv
from a3
group by artical_id
order by max_uv desc;

全部评论

相关推荐

05-29 20:34
门头沟学院 C++
KarlAllen_直通春招版:得做好直接春招的准备。学历差的话,一是面试要求会比学历好的严格不少,二是就算面试通过了也会被排序。总之暑期和秋招对于学历差的就是及其不友好
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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