这是数据库的一部分:
SessionID SessionStartTime SessionCloseTime
24 2012-10-16 01:00:06.000 2012-10-16 01:01:22.000
24 2012-10-16 01:00:08.000 2012-10-16 01:01:10.000
24 2012-10-16 01:00:16.000 2012-10-16 01:01:12.000
24 2012-10-16 01:00:30.000 2012-10-16 01:01:48.000
24 2012-10-16 01:00:41.000 2012-10-16 01:02:08.000
24 2012-10-16 01:00:48.000 2012-10-16 01:01:34.000
24 2012-10-16 01:00:56.000 2012-10-16 01:03:09.000
24 2012-10-16 01:01:02.000 2012-10-16 01:02:13.000
24 2012-10-16 01:01:05.000 2012-10-16 01:03:16.000
24 2012-10-16 01:01:09.000 2012-10-16 01:02:42.000
24 2012-10-16 01:01:15.000 2012-10-16 01:02:48.000
24 2012-10-16 01:01:18.000 2012-10-16 01:02:14.000
24 2012-10-16 01:01:18.000 2012-10-16 01:02:06.000
24 2012-10-16 01:01:42.000 2012-10-16 01:03:16.000
24 2012-10-16 01:01:45.000 2012-10-16 01:03:04.000
我想在此表中添加一个名为 SessionCount 的新列,然后我将能够看到呼叫峰值,我的意思是同时发生的最大会话数。
这个表应该是这样的:
SessionID SessionStartTime SessionCloseTime SessionCount
24 2012-10-16 01:00:06.000 2012-10-16 01:01:22.000 1
24 2012-10-16 01:00:08.000 2012-10-16 01:01:10.000 2
24 2012-10-16 01:00:16.000 2012-10-16 01:01:12.000 3
24 2012-10-16 01:00:30.000 2012-10-16 01:01:48.000 4
24 2012-10-16 01:00:41.000 2012-10-16 01:02:08.000 5
24 2012-10-16 01:00:48.000 2012-10-16 01:01:34.000 6
24 2012-10-16 01:00:56.000 2012-10-16 01:03:09.000 7
24 2012-10-16 01:01:02.000 2012-10-16 01:02:13.000 8
24 2012-10-16 01:01:05.000 2012-10-16 01:03:16.000 9
24 2012-10-16 01:01:09.000 2012-10-16 01:02:42.000 10
24 2012-10-16 01:01:15.000 2012-10-16 01:02:48.000 10
24 2012-10-16 01:01:18.000 2012-10-16 01:02:14.000 11
24 2012-10-16 01:01:18.000 2012-10-16 01:02:06.000 11
24 2012-10-16 01:01:42.000 2012-10-16 01:03:16.000 7
24 2012-10-16 01:01:45.000 2012-10-16 01:03:04.000 7
所以在这个表中,在 01:01:18 同时发生了最多 11 个呼叫峰值。01:01:18 有 11 个活动呼叫。如何在会话处于活动状态时计算会话,然后在会话完成时 +1,然后 -1?