美文网首页
SQL统计在线人数、最大并发人数

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

作者: cjlynn | 来源:发表于2020-07-28 09:59 被阅读0次

网上的一些统计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

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

相关文章

网友评论

      本文标题:SQL统计在线人数、最大并发人数

      本文链接:https://www.haomeiwen.com/subject/vqnxrktx.html