select artical_id,max(num_cnt) as max_uv
from
(select artical_id,
sum(num) over(partition by artical_id order by read_time asc,num desc) as num_cnt
from
(select artical_id,in_time as read_time,1 as num
from tb_user_log
where artical_id!=0
union all
select artical_id,out_time as read_time,-1 as num
from tb_user_log
where artical_id!=0
) as t1
)as t2
group by artical_id
order by max_uv desc

京公网安备 11010502036488号