select
artical_id
, max(uv) as max_uv
from (
select
artical_id
, time
, sum(df) over(order by time asc, df desc) as uv
from (
select
artical_id
, in_time as time
, 1 as df
from tb_user_log
where artical_id != 0
union all
select
artical_id
, out_time as time
, -1 as df
from tb_user_log
where artical_id != 0
) a
) b
group by 1
order by max_uv desc



京公网安备 11010502036488号