题解 | #每篇文章同一时刻最大在看人数# 无窗口函数
每篇文章同一时刻最大在看人数
https://www.nowcoder.com/practice/fe24c93008b84e9592b35faa15755e48
with cte as(select t1.artical_id, count(t2.in_time) + 1 as uv from tb_user_log t1 join tb_user_log t2 on t1.artical_id = t2.artical_id and t1.out_time >= t2.in_time and t1.out_time < t2.out_time where t1.artical_id != 0 group by 1,t1.in_time) select artical_id, max(uv) as max_uv from cte group by 1 order by 2 desc
利用join连接计算每个文章的每个阅读记录的与之同时的记录(即有时间交叉)