题解 | #牛客直播各科目同时在线人数#
牛客直播各科目同时在线人数
https://www.nowcoder.com/practice/d69677e41f9a4bf3b3ed7a42573e9490
select course_id, course_name, max(so) as max_num from ( select course_id,sum(uv) over(partition by course_id order by dt) as so from ( select course_id, user_id, in_datetime as dt, 1 as uv from attend_tb union select course_id, user_id, out_datetime as dt, -1 as uv from attend_tb ) a ) b join course_tb using(course_id) group by course_id, course_name order by course_id