题解 | #每篇文章同一时刻最大在看人数#
每篇文章同一时刻最大在看人数
http://www.nowcoder.com/practice/fe24c93008b84e9592b35faa15755e48
select artical_id, max(num) as max_uv from ( select artical_id, sum(diff) over(partition by artical_id order by in_time,diff DESC) as num from ( select artical_id, in_time, 1 diff from tb_user_log WHERE artical_id != 0 union all select artical_id, out_time, -1 diff from tb_user_log WHERE artical_id != 0 order by 1,2 )a)b group by 1 order by 2 desc