SQL统计在线人数、最大并发人数

2020-07-28  本文已影响0人  cjlynn

网上的一些统计sql统计不准确,在出现start_time相同的情况下,会统计出错,现修改如下:

select max(c)
from
(
    select count(*) as c
    from s_statistics_info a, s_statistics_info b
    where  a.start_time between b.start_time and b.end_time
    group by a.start_time,a.end_time
) c

子查询里面的统计是每一条记录的起止时间的在线人数
上一篇 下一篇

猜你喜欢

热点阅读