select artical_id, max(inst_view_cnt) max_uv from (select artical_id, sum(diff) over (partition by artical_id order by dt, diff desc) inst_view_cnt from (select artical_id, in_time dt, 1 diff from tb_user_log WHERE artical_id != 0 union all select artical_id, out_time dt, -1 diff from tb_user_log ...