Slow running query

  • Hi,

    I am trying to get some counts and it's running really slow. Any help would be really appreciated.

    The table has a call_id, start_time, and end_time. The table has thousands or records but I am parsing by day. When I include the ]group = 'Tech' it drops the working collection to about 800.


    I am trying to summarize the data by minute. Something saying that at says at xx:xx there where xx calls between the time. Thing is I need to count per minute and include everything that is in that minute. (I know, confusing. I included what i have so far.) The problem is, this is slow and if I run it for multiple days it's almost unusable.


    DECLARE @sDate AS SMALLDATETIME = '30 jan 2018';
    DECLARE @eDate AS SMALLDATETIME = '30 jan 2018';
    SET @eDate = DATEADD(MINUTE, -1, DATEADD(DAY, 1, @eDate)) -- set to 23:59 of the last day
    ;WITH DateCte
    AS (SELECT @sDate AS Day
      UNION ALL
      SELECT DATEADD(MINUTE, 5, Day) AS Day
      FROM DateCte
      WHERE DATEADD(MINUTE, 5, Day) <= @eDate),
      QueueCallsCte
    AS (SELECT call_id,
        DATEADD(MINUTE, DATEDIFF(MINUTE, 0, start_time), 0) start_time,
        DATEADD(MINUTE, DATEDIFF(MINUTE, 0, end_time), 0) end_time
      FROM dbo.QueueCallItems
      WHERE start_time
        BETWEEN @sDate AND @eDate
        AND group = 'Tech'
        AND type = 3)
    SELECT DateCte.Day,
       (SELECT COUNT(DISTINCT call_id) FROM QueueCallsCte WHERE DateCte.Day BETWEEN QueueCallsCte.start_time AND QueueCallsCte.end_time) CallCount
    FROM DateCte
    WHERE DATEPART(HOUR, DateCte.Day)
    BETWEEN 4 AND 18
    OPTION (MAXRECURSION 0);

  • If you'd provide some usable sample data -- CREATE TABLE and INSERT statements -- for QueueCallItems, I (and others) can code something up.  Sorry, but I just don't have additional time to volunteer to convert a picture of data to usable data.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Sorry, first time posting.

    This is the actual data that is returned by the second CTE.


    DECLARE @TempTable TABLE (call_id INT, start_time SMALLDATETIME, end_time SMALLDATETIME)

    INSERT INTO @TempTable VALUES (1780550, '2018-01-29 4:34:00', '2018-01-29 4:34:00'),
    (1780555, '2018-01-29 4:55:00', '2018-01-29 4:55:00'),
    (1780557, '2018-01-29 4:59:00', '2018-01-29 4:59:00'),
    (1780564, '2018-01-29 5:06:00', '2018-01-29 5:06:00'),
    (1780569, '2018-01-29 5:16:00', '2018-01-29 5:16:00'),
    (1780556, '2018-01-29 4:56:00', '2018-01-29 4:56:00'),
    (1780571, '2018-01-29 5:31:00', '2018-01-29 5:31:00'),
    (1780575, '2018-01-29 5:36:00', '2018-01-29 5:37:00'),
    (1780573, '2018-01-29 5:32:00', '2018-01-29 5:36:00'),
    (1780570, '2018-01-29 5:29:00', '2018-01-29 5:29:00'),
    (1780577, '2018-01-29 5:36:00', '2018-01-29 5:41:00'),
    (1780574, '2018-01-29 5:34:00', '2018-01-29 5:41:00'),
    (1780578, '2018-01-29 5:37:00', '2018-01-29 5:48:00'),
    (1780579, '2018-01-29 5:39:00', '2018-01-29 5:48:00'),
    (1780582, '2018-01-29 5:45:00', '2018-01-29 5:53:00'),
    (1780567, '2018-01-29 5:12:00', '2018-01-29 5:12:00'),
    (1780585, '2018-01-29 5:50:00', '2018-01-29 5:56:00'),
    (1780587, '2018-01-29 5:54:00', '2018-01-29 5:59:00'),
    (1780591, '2018-01-29 5:58:00', '2018-01-29 6:03:00'),
    (1780600, '2018-01-29 6:06:00', '2018-01-29 6:07:00'),
    (1780590, '2018-01-29 5:56:00', '2018-01-29 6:02:00'),
    (1780597, '2018-01-29 6:03:00', '2018-01-29 6:10:00'),
    (1780602, '2018-01-29 6:08:00', '2018-01-29 6:08:00'),
    (1780595, '2018-01-29 6:02:00', '2018-01-29 6:11:00'),
    (1780594, '2018-01-29 6:01:00', '2018-01-29 6:09:00'),
    (1780609, '2018-01-29 6:12:00', '2018-01-29 6:19:00'),
    (1780633, '2018-01-29 6:22:00', '2018-01-29 6:23:00'),
    (1780607, '2018-01-29 6:11:00', '2018-01-29 6:18:00'),
    (1780592, '2018-01-29 5:58:00', '2018-01-29 6:07:00'),
    (1780588, '2018-01-29 5:55:00', '2018-01-29 6:01:00'),
    (1780655, '2018-01-29 6:32:00', '2018-01-29 6:33:00'),
    (1780641, '2018-01-29 6:24:00', '2018-01-29 6:33:00'),
    (1780601, '2018-01-29 6:07:00', '2018-01-29 6:18:00'),
    (1780621, '2018-01-29 6:17:00', '2018-01-29 6:35:00'),
    (1780646, '2018-01-29 6:26:00', '2018-01-29 6:35:00'),
    (1780657, '2018-01-29 6:33:00', '2018-01-29 6:35:00'),
    (1780642, '2018-01-29 6:25:00', '2018-01-29 6:25:00'),
    (1780622, '2018-01-29 6:17:00', '2018-01-29 6:35:00'),
    (1780658, '2018-01-29 6:33:00', '2018-01-29 6:50:00'),
    (1780671, '2018-01-29 6:45:00', '2018-01-29 6:51:00'),
    (1780659, '2018-01-29 6:34:00', '2018-01-29 6:53:00'),
    (1780617, '2018-01-29 6:16:00', '2018-01-29 6:29:00'),
    (1780613, '2018-01-29 6:13:00', '2018-01-29 6:28:00'),
    (1780664, '2018-01-29 6:35:00', '2018-01-29 7:00:00'),
    (1780686, '2018-01-29 6:48:00', '2018-01-29 7:00:00'),
    (1780687, '2018-01-29 6:48:00', '2018-01-29 7:00:00'),
    (1780623, '2018-01-29 6:17:00', '2018-01-29 6:40:00'),
    (1780712, '2018-01-29 7:00:00', '2018-01-29 7:01:00'),
    (1780637, '2018-01-29 6:23:00', '2018-01-29 7:01:00'),
    (1780735, '2018-01-29 7:10:00', '2018-01-29 7:11:00'),
    (1780639, '2018-01-29 6:23:00', '2018-01-29 7:05:00'),
    (1780631, '2018-01-29 6:20:00', '2018-01-29 7:01:00'),
    (1780610, '2018-01-29 6:12:00', '2018-01-29 6:27:00'),
    (1780760, '2018-01-29 7:14:00', '2018-01-29 7:16:00'),
    (1780766, '2018-01-29 7:15:00', '2018-01-29 7:16:00'),
    (1780698, '2018-01-29 6:54:00', '2018-01-29 7:16:00'),
    (1780774, '2018-01-29 7:16:00', '2018-01-29 7:17:00'),
    (1780644, '2018-01-29 6:25:00', '2018-01-29 7:10:00'),
    (1780661, '2018-01-29 6:34:00', '2018-01-29 7:13:00'),
    (1780643, '2018-01-29 6:25:00', '2018-01-29 7:10:00'),
    (1780777, '2018-01-29 7:17:00', '2018-01-29 7:18:00'),
    (1780666, '2018-01-29 6:36:00', '2018-01-29 7:16:00'),
    (1780732, '2018-01-29 7:09:00', '2018-01-29 7:20:00'),
    (1780741, '2018-01-29 7:11:00', '2018-01-29 7:11:00'),
    (1780656, '2018-01-29 6:33:00', '2018-01-29 7:13:00'),
    (1780788, '2018-01-29 7:22:00', '2018-01-29 7:22:00'),
    (1780695, '2018-01-29 6:52:00', '2018-01-29 7:19:00'),
    (1780783, '2018-01-29 7:21:00', '2018-01-29 7:24:00'),
    (1780630, '2018-01-29 6:20:00', '2018-01-29 6:51:00'),
    (1780707, '2018-01-29 6:58:00', '2018-01-29 7:24:00'),
    (1780724, '2018-01-29 7:06:00', '2018-01-29 7:24:00'),
    (1780790, '2018-01-29 7:22:00', '2018-01-29 7:22:00'),
    (1780722, '2018-01-29 7:04:00', '2018-01-29 7:24:00'),
    (1780726, '2018-01-29 7:08:00', '2018-01-29 7:25:00'),
    (1780739, '2018-01-29 7:10:00', '2018-01-29 7:28:00'),
    (1780733, '2018-01-29 7:10:00', '2018-01-29 7:10:00'),
    (1780733, '2018-01-29 7:10:00', '2018-01-29 7:25:00'),
    (1780814, '2018-01-29 7:29:00', '2018-01-29 7:29:00'),
    (1780748, '2018-01-29 7:14:00', '2018-01-29 7:14:00'),
    (1780748, '2018-01-29 7:14:00', '2018-01-29 7:29:00'),
    (1780806, '2018-01-29 7:28:00', '2018-01-29 7:30:00'),
    (1780794, '2018-01-29 7:24:00', '2018-01-29 7:24:00'),
    (1780801, '2018-01-29 7:26:00', '2018-01-29 7:30:00'),
    (1780825, '2018-01-29 7:32:00', '2018-01-29 7:32:00'),
    (1780836, '2018-01-29 7:34:00', '2018-01-29 7:34:00'),
    (1780747, '2018-01-29 7:13:00', '2018-01-29 7:28:00'),
    (1780652, '2018-01-29 6:29:00', '2018-01-29 7:11:00'),
    (1780848, '2018-01-29 7:37:00', '2018-01-29 7:38:00'),
    (1780864, '2018-01-29 7:40:00', '2018-01-29 7:40:00'),
    (1780745, '2018-01-29 7:13:00', '2018-01-29 7:28:00'),
    (1780776, '2018-01-29 7:17:00', '2018-01-29 7:36:00'),
    (1780782, '2018-01-29 7:19:00', '2018-01-29 7:40:00'),
    (1780878, '2018-01-29 7:43:00', '2018-01-29 7:43:00'),
    (1780867, '2018-01-29 7:40:00', '2018-01-29 7:41:00'),
    (1780818, '2018-01-29 7:30:00', '2018-01-29 7:43:00'),
    (1780880, '2018-01-29 7:43:00', '2018-01-29 7:45:00'),
    (1780884, '2018-01-29 7:44:00', '2018-01-29 7:45:00'),
    (1780870, '2018-01-29 7:41:00', '2018-01-29 7:47:00'),
    (1780682, '2018-01-29 6:46:00', '2018-01-29 7:18:00'),
    (1780883, '2018-01-29 7:44:00', '2018-01-29 7:50:00'),
    (1780668, '2018-01-29 6:36:00', '2018-01-29 7:16:00'),
    (1780791, '2018-01-29 7:23:00', '2018-01-29 7:42:00'),
    (1780787, '2018-01-29 7:22:00', '2018-01-29 7:41:00'),
    (1780799, '2018-01-29 7:25:00', '2018-01-29 7:42:00'),
    (1780902, '2018-01-29 7:51:00', '2018-01-29 7:52:00'),
    (1780910, '2018-01-29 7:54:00', '2018-01-29 7:54:00'),
    (1780893, '2018-01-29 7:48:00', '2018-01-29 7:54:00'),
    (1780813, '2018-01-29 7:29:00', '2018-01-29 7:52:00'),
    (1780916, '2018-01-29 7:56:00', '2018-01-29 7:58:00'),
    (1780771, '2018-01-29 7:15:00', '2018-01-29 7:36:00'),
    (1780920, '2018-01-29 7:57:00', '2018-01-29 7:59:00'),
    (1780800, '2018-01-29 7:25:00', '2018-01-29 7:50:00'),
    (1780697, '2018-01-29 6:54:00', '2018-01-29 7:21:00'),
    (1780803, '2018-01-29 7:27:00', '2018-01-29 7:51:00'),
    (1780937, '2018-01-29 8:02:00', '2018-01-29 8:03:00'),
    (1780816, '2018-01-29 7:29:00', '2018-01-29 8:01:00'),
    (1780949, '2018-01-29 8:06:00', '2018-01-29 8:06:00'),
    (1780947, '2018-01-29 8:05:00', '2018-01-29 8:06:00'),
    (1780829, '2018-01-29 7:32:00', '2018-01-29 8:03:00'),
    (1780838, '2018-01-29 7:34:00', '2018-01-29 8:04:00'),
    (1780784, '2018-01-29 7:31:00', '2018-01-29 7:31:00'),
    (1780784, '2018-01-29 7:31:00', '2018-01-29 8:02:00'),
    (1780941, '2018-01-29 8:03:00', '2018-01-29 8:03:00'),
    (1780918, '2018-01-29 7:56:00', '2018-01-29 8:09:00'),
    (1780957, '2018-01-29 8:08:00', '2018-01-29 8:09:00'),
    (1780964, '2018-01-29 8:10:00', '2018-01-29 8:11:00'),
    (1780839, '2018-01-29 7:34:00', '2018-01-29 8:08:00'),
    (1780819, '2018-01-29 7:30:00', '2018-01-29 8:01:00'),
    (1780857, '2018-01-29 7:39:00', '2018-01-29 8:09:00'),
    (1780845, '2018-01-29 7:36:00', '2018-01-29 8:09:00'),
    (1780984, '2018-01-29 8:15:00', '2018-01-29 8:21:00'),
    (1780808, '2018-01-29 7:29:00', '2018-01-29 7:56:00'),
    (1780815, '2018-01-29 7:29:00', '2018-01-29 7:54:00'),
    (1780866, '2018-01-29 7:40:00', '2018-01-29 8:17:00'),
    (1781004, '2018-01-29 8:22:00', '2018-01-29 8:23:00'),
    (1780895, '2018-01-29 7:50:00', '2018-01-29 8:25:00'),
    (1781033, '2018-01-29 8:27:00', '2018-01-29 8:27:00'),
    (1780869, '2018-01-29 7:40:00', '2018-01-29 8:18:00'),
    (1781034, '2018-01-29 8:27:00', '2018-01-29 8:28:00'),
    (1780873, '2018-01-29 7:41:00', '2018-01-29 8:22:00'),
    (1780879, '2018-01-29 7:43:00', '2018-01-29 8:24:00'),
    (1781031, '2018-01-29 8:27:00', '2018-01-29 8:27:00'),
    (1781045, '2018-01-29 8:30:00', '2018-01-29 8:31:00'),
    (1780925, '2018-01-29 7:59:00', '2018-01-29 8:30:00'),
    (1781048, '2018-01-29 8:31:00', '2018-01-29 8:33:00'),
    (1780914, '2018-01-29 7:55:00', '2018-01-29 8:28:00'),
    (1781051, '2018-01-29 8:32:00', '2018-01-29 8:33:00'),
    (1780950, '2018-01-29 8:06:00', '2018-01-29 8:35:00'),
    (1781071, '2018-01-29 8:38:00', '2018-01-29 8:38:00'),
    (1781070, '2018-01-29 8:38:00', '2018-01-29 8:39:00'),
    (1780926, '2018-01-29 7:59:00', '2018-01-29 8:30:00'),
    (1780913, '2018-01-29 7:55:00', '2018-01-29 8:25:00'),
    (1781075, '2018-01-29 8:39:00', '2018-01-29 8:40:00'),
    (1780781, '2018-01-29 7:18:00', '2018-01-29 7:39:00'),
    (1781062, '2018-01-29 8:35:00', '2018-01-29 8:40:00'),
    (1781082, '2018-01-29 8:43:00', '2018-01-29 8:43:00'),
    (1780951, '2018-01-29 8:07:00', '2018-01-29 8:39:00'),
    (1781084, '2018-01-29 8:43:00', '2018-01-29 8:43:00'),
    (1780928, '2018-01-29 7:59:00', '2018-01-29 8:32:00'),
    (1781102, '2018-01-29 8:47:00', '2018-01-29 8:48:00'),
    (1781101, '2018-01-29 8:48:00', '2018-01-29 8:48:00'),
    (1781104, '2018-01-29 8:48:00', '2018-01-29 8:49:00'),
    (1781107, '2018-01-29 8:49:00', '2018-01-29 8:49:00'),
    (1781108, '2018-01-29 8:49:00', '2018-01-29 8:50:00'),
    (1781109, '2018-01-29 8:49:00', '2018-01-29 8:50:00'),
    (1781113, '2018-01-29 8:51:00', '2018-01-29 8:52:00'),
    (1781059, '2018-01-29 8:34:00', '2018-01-29 8:34:00'),
    (1781059, '2018-01-29 8:36:00', '2018-01-29 8:36:00'),
    (1781115, '2018-01-29 8:52:00', '2018-01-29 8:53:00'),
    (1781120, '2018-01-29 8:53:00', '2018-01-29 8:53:00'),
    (1781119, '2018-01-29 8:53:00', '2018-01-29 8:53:00'),
    (1780765, '2018-01-29 7:15:00', '2018-01-29 7:29:00'),
    (1780970, '2018-01-29 8:11:00', '2018-01-29 8:42:00'),
    (1780946, '2018-01-29 8:05:00', '2018-01-29 8:34:00'),
    (1781081, '2018-01-29 8:42:00', '2018-01-29 8:56:00'),
    (1781131, '2018-01-29 8:56:00', '2018-01-29 8:57:00'),
    (1780860, '2018-01-29 7:39:00', '2018-01-29 8:14:00'),
    (1781132, '2018-01-29 8:56:00', '2018-01-29 8:57:00'),
    (1781135, '2018-01-29 8:57:00', '2018-01-29 8:58:00'),
    (1780991, '2018-01-29 8:17:00', '2018-01-29 8:55:00'),
    (1780993, '2018-01-29 8:18:00', '2018-01-29 8:57:00'),
    (1780986, '2018-01-29 8:16:00', '2018-01-29 8:54:00'),
    (1781153, '2018-01-29 8:59:00', '2018-01-29 9:00:00'),
    (1781151, '2018-01-29 8:59:00', '2018-01-29 9:00:00'),
    (1781124, '2018-01-29 8:54:00', '2018-01-29 8:54:00'),
    (1781017, '2018-01-29 8:25:00', '2018-01-29 9:01:00'),
    (1780992, '2018-01-29 8:18:00', '2018-01-29 8:55:00'),
    (1781149, '2018-01-29 8:59:00', '2018-01-29 9:03:00'),
    (1780832, '2018-01-29 7:33:00', '2018-01-29 8:04:00'),
    (1781014, '2018-01-29 8:24:00', '2018-01-29 9:00:00'),
    (1781025, '2018-01-29 8:26:00', '2018-01-29 9:03:00'),
    (1781003, '2018-01-29 8:20:00', '2018-01-29 8:59:00'),
    (1780998, '2018-01-29 8:18:00', '2018-01-29 8:59:00'),
    (1781137, '2018-01-29 8:57:00', '2018-01-29 9:09:00'),
    (1780903, '2018-01-29 7:51:00', '2018-01-29 7:51:00'),
    (1780903, '2018-01-29 8:01:00', '2018-01-29 8:01:00'),
    (1781202, '2018-01-29 9:08:00', '2018-01-29 9:10:00'),
    (1781064, '2018-01-29 8:36:00', '2018-01-29 9:10:00'),
    (1781207, '2018-01-29 9:11:00', '2018-01-29 9:11:00'),
    (1781039, '2018-01-29 8:29:00', '2018-01-29 9:05:00'),
    (1781211, '2018-01-29 9:12:00', '2018-01-29 9:12:00'),
    (1780981, '2018-01-29 8:14:00', '2018-01-29 8:44:00'),
    (1781057, '2018-01-29 8:34:00', '2018-01-29 9:08:00'),
    (1781054, '2018-01-29 8:33:00', '2018-01-29 9:08:00'),
    (1781052, '2018-01-29 8:32:00', '2018-01-29 9:07:00'),
    (1781079, '2018-01-29 8:40:00', '2018-01-29 9:13:00'),
    (1781032, '2018-01-29 8:27:00', '2018-01-29 9:05:00'),
    (1781021, '2018-01-29 8:26:00', '2018-01-29 9:01:00'),
    (1781230, '2018-01-29 9:18:00', '2018-01-29 9:19:00'),
    (1781217, '2018-01-29 9:14:00', '2018-01-29 9:19:00'),
    (1781178, '2018-01-29 9:03:00', '2018-01-29 9:04:00'),
    (1781129, '2018-01-29 8:54:00', '2018-01-29 9:20:00'),
    (1781255, '2018-01-29 9:24:00', '2018-01-29 9:24:00'),
    (1780983, '2018-01-29 8:15:00', '2018-01-29 8:44:00'),
    (1781256, '2018-01-29 9:24:00', '2018-01-29 9:29:00'),
    (1781087, '2018-01-29 8:44:00', '2018-01-29 9:16:00'),
    (1781130, '2018-01-29 8:56:00', '2018-01-29 9:23:00'),
    (1781118, '2018-01-29 8:53:00', '2018-01-29 9:18:00'),
    (1781258, '2018-01-29 9:24:00', '2018-01-29 9:33:00'),
    (1781288, '2018-01-29 9:34:00', '2018-01-29 9:34:00'),
    (1781293, '2018-01-29 9:35:00', '2018-01-29 9:35:00'),
    (1781181, '2018-01-29 9:03:00', '2018-01-29 9:30:00'),
    (1781066, '2018-01-29 8:36:00', '2018-01-29 9:11:00'),
    (1781022, '2018-01-29 8:26:00', '2018-01-29 9:02:00'),
    (1781260, '2018-01-29 9:25:00', '2018-01-29 9:37:00'),
    (1781187, '2018-01-29 9:05:00', '2018-01-29 9:33:00'),
    (1781302, '2018-01-29 9:38:00', '2018-01-29 9:39:00'),
    (1781305, '2018-01-29 9:38:00', '2018-01-29 9:39:00'),
    (1781307, '2018-01-29 9:38:00', '2018-01-29 9:40:00'),
    (1781206, '2018-01-29 9:10:00', '2018-01-29 9:36:00'),
    (1781294, '2018-01-29 9:35:00', '2018-01-29 9:40:00'),
    (1781077, '2018-01-29 8:40:00', '2018-01-29 9:14:00'),
    (1781121, '2018-01-29 8:53:00', '2018-01-29 8:54:00'),
    (1781121, '2018-01-29 8:58:00', '2018-01-29 8:58:00'),
    (1781297, '2018-01-29 9:36:00', '2018-01-29 9:36:00'),
    (1781188, '2018-01-29 9:05:00', '2018-01-29 9:34:00'),
    (1781189, '2018-01-29 9:06:00', '2018-01-29 9:34:00'),
    (1781238, '2018-01-29 9:20:00', '2018-01-29 9:40:00'),
    (1781237, '2018-01-29 9:20:00', '2018-01-29 9:40:00'),
    (1781265, '2018-01-29 9:25:00', '2018-01-29 9:42:00'),
    (1781147, '2018-01-29 8:59:00', '2018-01-29 9:27:00'),
    (1781332, '2018-01-29 9:43:00', '2018-01-29 9:48:00'),
    (1781278, '2018-01-29 9:30:00', '2018-01-29 9:46:00'),
    (1781267, '2018-01-29 9:26:00', '2018-01-29 9:42:00'),
    (1781100, '2018-01-29 8:47:00', '2018-01-29 9:17:00'),
    (1781174, '2018-01-29 9:02:00', '2018-01-29 9:28:00'),
    (1781356, '2018-01-29 9:50:00', '2018-01-29 9:51:00'),
    (1781209, '2018-01-29 9:11:00', '2018-01-29 9:37:00'),
    (1781239, '2018-01-29 9:20:00', '2018-01-29 9:40:00'),
    (1781200, '2018-01-29 9:08:00', '2018-01-29 9:34:00'),
    (1781274, '2018-01-29 9:27:00', '2018-01-29 9:45:00'),
    (1781279, '2018-01-29 9:32:00', '2018-01-29 9:49:00'),
    (1781276, '2018-01-29 9:29:00', '2018-01-29 9:45:00'),
    (1781314, '2018-01-29 9:39:00', '2018-01-29 9:54:00'),
    (1781379, '2018-01-29 9:57:00', '2018-01-29 9:57:00'),
    (1781272, '2018-01-29 9:27:00', '2018-01-29 9:44:00'),
    (1781333, '2018-01-29 9:43:00', '2018-01-29 9:56:00'),
    (1781261, '2018-01-29 9:26:00', '2018-01-29 9:44:00'),
    (1781320, '2018-01-29 9:40:00', '2018-01-29 9:55:00'),
    (1781354, '2018-01-29 9:50:00', '2018-01-29 9:51:00'),
    (1781357, '2018-01-29 9:51:00', '2018-01-29 9:59:00'),
    (1781353, '2018-01-29 9:50:00', '2018-01-29 9:58:00'),
    (1781362, '2018-01-29 9:51:00', '2018-01-29 10:01:00'),
    (1781316, '2018-01-29 9:39:00', '2018-01-29 9:40:00'),
    (1781321, '2018-01-29 9:40:00', '2018-01-29 9:56:00'),
    (1781304, '2018-01-29 9:38:00', '2018-01-29 9:52:00'),
    (1781431, '2018-01-29 10:10:00', '2018-01-29 10:11:00'),
    (1781376, '2018-01-29 9:55:00', '2018-01-29 10:09:00'),
    (1781361, '2018-01-29 9:53:00', '2018-01-29 10:02:00'),
    (1781373, '2018-01-29 9:54:00', '2018-01-29 10:09:00'),
    (1781360, '2018-01-29 9:51:00', '2018-01-29 10:00:00'),
    (1781388, '2018-01-29 10:00:00', '2018-01-29 10:12:00'),
    (1781371, '2018-01-29 9:54:00', '2018-01-29 10:05:00'),
    (1781432, '2018-01-29 10:10:00', '2018-01-29 10:17:00'),
    (1781436, '2018-01-29 10:11:00', '2018-01-29 10:11:00'),
    (1781475, '2018-01-29 10:18:00', '2018-01-29 10:21:00'),
    (1781370, '2018-01-29 9:54:00', '2018-01-29 10:03:00'),
    (1781399, '2018-01-29 10:02:00', '2018-01-29 10:14:00'),
    (1781290, '2018-01-29 9:34:00', '2018-01-29 9:50:00'),
    (1781501, '2018-01-29 10:26:00', '2018-01-29 10:27:00'),
    (1781498, '2018-01-29 10:25:00', '2018-01-29 10:25:00'),
    (1781454, '2018-01-29 10:14:00', '2018-01-29 10:27:00'),
    (1781496, '2018-01-29 10:24:00', '2018-01-29 10:27:00'),
    (1781502, '2018-01-29 10:26:00', '2018-01-29 10:28:00'),
    (1781396, '2018-01-29 10:01:00', '2018-01-29 10:13:00'),
    (1781414, '2018-01-29 10:05:00', '2018-01-29 10:22:00'),
    (1781377, '2018-01-29 9:57:00', '2018-01-29 10:11:00'),
    (1781420, '2018-01-29 10:06:00', '2018-01-29 10:28:00'),
    (1781455, '2018-01-29 10:32:00', '2018-01-29 10:33:00'),
    (1780872, '2018-01-29 7:42:00', '2018-01-29 8:24:00'),
    (1781495, '2018-01-29 10:24:00', '2018-01-29 10:35:00'),
    (1781429, '2018-01-29 10:09:00', '2018-01-29 10:29:00'),
    (1781561, '2018-01-29 10:38:00', '2018-01-29 10:40:00'),
    (1781554, '2018-01-29 10:35:00', '2018-01-29 10:42:00'),
    (1781511, '2018-01-29 10:29:00', '2018-01-29 10:42:00'),
    (1781451, '2018-01-29 10:13:00', '2018-01-29 10:35:00'),
    (1781449, '2018-01-29 10:13:00', '2018-01-29 10:34:00'),
    (1781409, '2018-01-29 10:04:00', '2018-01-29 10:19:00'),
    (1781595, '2018-01-29 10:43:00', '2018-01-29 10:44:00'),
    (1781534, '2018-01-29 10:33:00', '2018-01-29 10:33:00'),
    (1781457, '2018-01-29 10:14:00', '2018-01-29 10:43:00'),
    (1781553, '2018-01-29 10:37:00', '2018-01-29 10:47:00'),
    (1781392, '2018-01-29 10:01:00', '2018-01-29 10:12:00'),
    (1781598, '2018-01-29 10:44:00', '2018-01-29 10:44:00'),
    (1781478, '2018-01-29 10:20:00', '2018-01-29 10:50:00'),
    (1781617, '2018-01-29 10:50:00', '2018-01-29 10:50:00'),
    (1781476, '2018-01-29 10:18:00', '2018-01-29 10:52:00'),
    (1781620, '2018-01-29 10:51:00', '2018-01-29 10:52:00'),
    (1781604, '2018-01-29 10:46:00', '2018-01-29 10:53:00'),
    (1781437, '2018-01-29 10:11:00', '2018-01-29 10:30:00'),
    (1781559, '2018-01-29 10:36:00', '2018-01-29 10:55:00'),
    (1781461, '2018-01-29 10:15:00', '2018-01-29 10:54:00'),
    (1781458, '2018-01-29 10:15:00', '2018-01-29 10:47:00'),
    (1781651, '2018-01-29 10:58:00', '2018-01-29 10:59:00'),
    (1781625, '2018-01-29 10:53:00', '2018-01-29 10:59:00'),
    (1781540, '2018-01-29 10:34:00', '2018-01-29 10:59:00'),
    (1781464, '2018-01-29 10:16:00', '2018-01-29 10:56:00'),
    (1781662, '2018-01-29 10:59:00', '2018-01-29 11:01:00'),
    (1781660, '2018-01-29 10:59:00', '2018-01-29 11:02:00'),
    (1781674, '2018-01-29 11:03:00', '2018-01-29 11:04:00'),
    (1781678, '2018-01-29 11:03:00', '2018-01-29 11:04:00'),
    (1781656, '2018-01-29 10:58:00', '2018-01-29 10:59:00'),
    (1781497, '2018-01-29 10:25:00', '2018-01-29 10:57:00'),
    (1781543, '2018-01-29 10:34:00', '2018-01-29 11:06:00'),
    (1781439, '2018-01-29 10:14:00', '2018-01-29 10:14:00'),
    (1781439, '2018-01-29 10:14:00', '2018-01-29 10:44:00'),
    (1781484, '2018-01-29 10:22:00', '2018-01-29 10:56:00'),
    (1781692, '2018-01-29 11:08:00', '2018-01-29 11:09:00'),
    (1781453, '2018-01-29 10:15:00', '2018-01-29 10:44:00'),
    (1781657, '2018-01-29 10:59:00', '2018-01-29 11:09:00'),
    (1781487, '2018-01-29 10:23:00', '2018-01-29 10:57:00'),
    (1781571, '2018-01-29 10:37:00', '2018-01-29 11:09:00'),
    (1781710, '2018-01-29 11:11:00', '2018-01-29 11:12:00'),
    (1781584, '2018-01-29 10:42:00', '2018-01-29 11:10:00'),
    (1781589, '2018-01-29 10:43:00', '2018-01-29 11:11:00'),
    (1781560, '2018-01-29 10:36:00', '2018-01-29 11:09:00'),
    (1781503, '2018-01-29 10:26:00', '2018-01-29 11:02:00'),
    (1781600, '2018-01-29 10:44:00', '2018-01-29 11:13:00'),
    (1781720, '2018-01-29 11:13:00', '2018-01-29 11:13:00'),
    (1781743, '2018-01-29 11:18:00', '2018-01-29 11:19:00'),
    (1781591, '2018-01-29 10:43:00', '2018-01-29 11:12:00'),
    (1781500, '2018-01-29 10:26:00', '2018-01-29 11:02:00'),
    (1781412, '2018-01-29 10:06:00', '2018-01-29 10:24:00'),
    (1781754, '2018-01-29 11:21:00', '2018-01-29 11:22:00'),
    (1781764, '2018-01-29 11:24:00', '2018-01-29 11:24:00'),
    (1781762, '2018-01-29 11:23:00', '2018-01-29 11:24:00'),
    (1781539, '2018-01-29 10:33:00', '2018-01-29 11:06:00'),
    (1781611, '2018-01-29 10:48:00', '2018-01-29 11:17:00'),
    (1781765, '2018-01-29 11:25:00', '2018-01-29 11:26:00'),
    (1781621, '2018-01-29 10:51:00', '2018-01-29 11:18:00'),
    (1781744, '2018-01-29 11:18:00', '2018-01-29 11:26:00'),
    (1781640, '2018-01-29 10:56:00', '2018-01-29 11:24:00'),
    (1781781, '2018-01-29 11:29:00', '2018-01-29 11:30:00'),
    (1781649, '2018-01-29 10:57:00', '2018-01-29 11:28:00'),
    (1781610, '2018-01-29 10:48:00', '2018-01-29 11:16:00'),
    (1781772, '2018-01-29 11:25:00', '2018-01-29 11:26:00'),
    (1781751, '2018-01-29 11:20:00', '2018-01-29 11:32:00'),
    (1781691, '2018-01-29 11:06:00', '2018-01-29 11:30:00'),
    (1781688, '2018-01-29 11:06:00', '2018-01-29 11:30:00'),
    (1781601, '2018-01-29 10:44:00', '2018-01-29 11:13:00'),
    (1781708, '2018-01-29 11:10:00', '2018-01-29 11:36:00'),
    (1781829, '2018-01-29 11:40:00', '2018-01-29 11:43:00'),
    (1781706, '2018-01-29 11:10:00', '2018-01-29 11:32:00'),
    (1781747, '2018-01-29 11:19:00', '2018-01-29 11:39:00'),
    (1781707, '2018-01-29 11:10:00', '2018-01-29 11:34:00'),
    (1781766, '2018-01-29 11:24:00', '2018-01-29 11:40:00'),
    (1781835, '2018-01-29 11:42:00', '2018-01-29 11:42:00'),
    (1781844, '2018-01-29 11:49:00', '2018-01-29 11:49:00'),
    (1781844, '2018-01-29 11:49:00', '2018-01-29 11:49:00'),
    (1781723, '2018-01-29 11:13:00', '2018-01-29 11:36:00'),
    (1781838, '2018-01-29 11:42:00', '2018-01-29 11:50:00'),
    (1781624, '2018-01-29 10:52:00', '2018-01-29 11:21:00'),
    (1781865, '2018-01-29 11:51:00', '2018-01-29 11:52:00'),
    (1781732, '2018-01-29 11:16:00', '2018-01-29 11:37:00'),
    (1781873, '2018-01-29 11:53:00', '2018-01-29 11:54:00'),
    (1781745, '2018-01-29 11:19:00', '2018-01-29 11:39:00'),
    (1781644, '2018-01-29 10:57:00', '2018-01-29 11:27:00'),
    (1781878, '2018-01-29 11:56:00', '2018-01-29 11:57:00'),
    (1781771, '2018-01-29 11:26:00', '2018-01-29 11:45:00'),
    (1781817, '2018-01-29 11:37:00', '2018-01-29 11:59:00'),
    (1781807, '2018-01-29 11:35:00', '2018-01-29 11:54:00'),
    (1781890, '2018-01-29 12:01:00', '2018-01-29 12:02:00'),
    (1781814, '2018-01-29 11:37:00', '2018-01-29 12:00:00'),
    (1781689, '2018-01-29 11:06:00', '2018-01-29 11:29:00'),
    (1781886, '2018-01-29 11:58:00', '2018-01-29 12:03:00'),
    (1781815, '2018-01-29 11:37:00', '2018-01-29 12:02:00'),
    (1781820, '2018-01-29 11:38:00', '2018-01-29 12:03:00'),
    (1781792, '2018-01-29 11:32:00', '2018-01-29 11:50:00'),
    (1781910, '2018-01-29 12:05:00', '2018-01-29 12:06:00'),
    (1781808, '2018-01-29 11:35:00', '2018-01-29 11:58:00'),
    (1781778, '2018-01-29 11:27:00', '2018-01-29 11:47:00'),
    (1781799, '2018-01-29 11:34:00', '2018-01-29 11:34:00'),
    (1781799, '2018-01-29 11:40:00', '2018-01-29 11:40:00'),
    (1781927, '2018-01-29 12:08:00', '2018-01-29 12:10:00'),
    (1781811, '2018-01-29 11:36:00', '2018-01-29 11:59:00'),
    (1781790, '2018-01-29 11:31:00', '2018-01-29 11:49:00'),
    (1781839, '2018-01-29 11:41:00', '2018-01-29 12:08:00'),
    (1781920, '2018-01-29 12:06:00', '2018-01-29 12:07:00'),
    (1781861, '2018-01-29 11:50:00', '2018-01-29 12:14:00'),
    (1781957, '2018-01-29 12:15:00', '2018-01-29 12:16:00'),
    (1781942, '2018-01-29 12:12:00', '2018-01-29 12:19:00'),
    (1781971, '2018-01-29 12:19:00', '2018-01-29 12:20:00'),
    (1781973, '2018-01-29 12:20:00', '2018-01-29 12:21:00'),
    (1781950, '2018-01-29 12:13:00', '2018-01-29 12:24:00'),
    (1781977, '2018-01-29 12:23:00', '2018-01-29 12:24:00'),
    (1781847, '2018-01-29 11:46:00', '2018-01-29 12:13:00'),
    (1781960, '2018-01-29 12:16:00', '2018-01-29 12:16:00'),
    (1781947, '2018-01-29 12:13:00', '2018-01-29 12:27:00'),
    (1781988, '2018-01-29 12:27:00', '2018-01-29 12:28:00'),
    (1781627, '2018-01-29 10:53:00', '2018-01-29 11:22:00'),
    (1781987, '2018-01-29 12:27:00', '2018-01-29 12:28:00'),
    (1781841, '2018-01-29 11:42:00', '2018-01-29 12:11:00'),
    (1781846, '2018-01-29 11:46:00', '2018-01-29 12:13:00'),
    (1781912, '2018-01-29 12:05:00', '2018-01-29 12:31:00'),
    (1781871, '2018-01-29 11:52:00', '2018-01-29 12:22:00'),
    (1782001, '2018-01-29 12:32:00', '2018-01-29 12:33:00'),
    (1781862, '2018-01-29 11:51:00', '2018-01-29 12:15:00'),
    (1781737, '2018-01-29 11:16:00', '2018-01-29 11:38:00'),
    (1781970, '2018-01-29 12:19:00', '2018-01-29 12:37:00'),
    (1781979, '2018-01-29 12:24:00', '2018-01-29 12:37:00'),
    (1781892, '2018-01-29 12:01:00', '2018-01-29 12:34:00'),
    (1782020, '2018-01-29 12:38:00', '2018-01-29 12:39:00'),
    (1782002, '2018-01-29 12:33:00', '2018-01-29 12:33:00'),
    (1781985, '2018-01-29 12:26:00', '2018-01-29 12:40:00'),
    (1782016, '2018-01-29 12:37:00', '2018-01-29 12:41:00'),
    (1781832, '2018-01-29 11:41:00', '2018-01-29 12:06:00'),
    (1781921, '2018-01-29 12:07:00', '2018-01-29 12:38:00'),
    (1781877, '2018-01-29 11:56:00', '2018-01-29 12:30:00'),
    (1782028, '2018-01-29 12:41:00', '2018-01-29 12:44:00'),
    (1781884, '2018-01-29 11:58:00', '2018-01-29 12:32:00'),
    (1782052, '2018-01-29 12:48:00', '2018-01-29 12:49:00'),
    (1781896, '2018-01-29 12:03:00', '2018-01-29 12:34:00'),
    (1781881, '2018-01-29 11:57:00', '2018-01-29 12:30:00'),
    (1781961, '2018-01-29 12:17:00', '2018-01-29 12:50:00'),
    (1781969, '2018-01-29 12:20:00', '2018-01-29 12:53:00'),
    (1782047, '2018-01-29 12:45:00', '2018-01-29 12:46:00'),
    (1781827, '2018-01-29 11:39:00', '2018-01-29 12:03:00'),
    (1781991, '2018-01-29 12:28:00', '2018-01-29 12:54:00'),
    (1781941, '2018-01-29 12:13:00', '2018-01-29 12:13:00'),
    (1781941, '2018-01-29 12:13:00', '2018-01-29 12:49:00'),
    (1781986, '2018-01-29 12:26:00', '2018-01-29 12:54:00'),
    (1782086, '2018-01-29 12:58:00', '2018-01-29 12:59:00'),
    (1781938, '2018-01-29 12:11:00', '2018-01-29 12:48:00'),
    (1782095, '2018-01-29 12:59:00', '2018-01-29 13:00:00'),
    (1782097, '2018-01-29 13:00:00', '2018-01-29 13:04:00'),
    (1781935, '2018-01-29 12:10:00', '2018-01-29 12:45:00'),
    (1782055, '2018-01-29 12:50:00', '2018-01-29 13:04:00'),
    (1782115, '2018-01-29 13:05:00', '2018-01-29 13:05:00'),
    (1782088, '2018-01-29 12:58:00', '2018-01-29 12:59:00'),
    (1782075, '2018-01-29 12:56:00', '2018-01-29 13:10:00'),
    (1782126, '2018-01-29 13:09:00', '2018-01-29 13:10:00'),
    (1782024, '2018-01-29 12:40:00', '2018-01-29 13:00:00'),
    (1782022, '2018-01-29 12:40:00', '2018-01-29 12:58:00'),
    (1782017, '2018-01-29 12:38:00', '2018-01-29 12:58:00'),
    (1782079, '2018-01-29 12:57:00', '2018-01-29 13:12:00'),
    (1782127, '2018-01-29 13:09:00', '2018-01-29 13:12:00'),
    (1782014, '2018-01-29 12:36:00', '2018-01-29 12:58:00'),
    (1782149, '2018-01-29 13:13:00', '2018-01-29 13:14:00'),
    (1782152, '2018-01-29 13:14:00', '2018-01-29 13:14:00'),
    (1782130, '2018-01-29 13:09:00', '2018-01-29 13:19:00'),
    (1782060, '2018-01-29 12:51:00', '2018-01-29 13:19:00'),
    (1782161, '2018-01-29 13:17:00', '2018-01-29 13:17:00'),
    (1781995, '2018-01-29 12:29:00', '2018-01-29 12:57:00'),
    (1782155, '2018-01-29 13:15:00', '2018-01-29 13:21:00'),
    (1782158, '2018-01-29 13:15:00', '2018-01-29 13:16:00'),
    (1782172, '2018-01-29 13:21:00', '2018-01-29 13:22:00'),
    (1781967, '2018-01-29 12:19:00', '2018-01-29 12:52:00'),
    (1782048, '2018-01-29 12:47:00', '2018-01-29 13:14:00'),
    (1782034, '2018-01-29 12:41:00', '2018-01-29 13:03:00'),
    (1782058, '2018-01-29 12:50:00', '2018-01-29 13:22:00'),
    (1781824, '2018-01-29 11:39:00', '2018-01-29 12:05:00'),
    (1782094, '2018-01-29 12:59:00', '2018-01-29 13:25:00'),
    (1782198, '2018-01-29 13:29:00', '2018-01-29 13:30:00'),
    (1782108, '2018-01-29 13:02:00', '2018-01-29 13:26:00'),
    (1782222, '2018-01-29 13:34:00', '2018-01-29 13:35:00'),
    (1782182, '2018-01-29 13:24:00', '2018-01-29 13:36:00'),
    (1782187, '2018-01-29 13:27:00', '2018-01-29 13:36:00'),
    (1782220, '2018-01-29 13:34:00', '2018-01-29 13:34:00'),
    (1782227, '2018-01-29 13:36:00', '2018-01-29 13:36:00'),
    (1782118, '2018-01-29 13:06:00', '2018-01-29 13:34:00'),
    (1782111, '2018-01-29 13:03:00', '2018-01-29 13:30:00'),
    (1782180, '2018-01-29 13:23:00', '2018-01-29 13:24:00'),
    (1782113, '2018-01-29 13:07:00', '2018-01-29 13:38:00'),
    (1782139, '2018-01-29 13:11:00', '2018-01-29 13:39:00'),
    (1782148, '2018-01-29 13:12:00', '2018-01-29 13:40:00'),
    (1782112, '2018-01-29 13:03:00', '2018-01-29 13:28:00'),
    (1782183, '2018-01-29 13:24:00', '2018-01-29 13:44:00'),
    (1782175, '2018-01-29 13:22:00', '2018-01-29 13:22:00'),
    (1782175, '2018-01-29 13:25:00', '2018-01-29 13:25:00'),
    (1782215, '2018-01-29 13:33:00', '2018-01-29 13:48:00'),
    (1782254, '2018-01-29 13:48:00', '2018-01-29 13:49:00'),
    (1782176, '2018-01-29 13:22:00', '2018-01-29 13:43:00'),
    (1782261, '2018-01-29 13:49:00', '2018-01-29 13:50:00'),
    (1782226, '2018-01-29 13:37:00', '2018-01-29 13:37:00'),
    (1782226, '2018-01-29 13:37:00', '2018-01-29 13:38:00'),
    (1782119, '2018-01-29 13:50:00', '2018-01-29 13:51:00'),
    (1782263, '2018-01-29 13:50:00', '2018-01-29 13:50:00'),
    (1782209, '2018-01-29 13:32:00', '2018-01-29 13:47:00'),
    (1782232, '2018-01-29 13:38:00', '2018-01-29 13:54:00'),
    (1782166, '2018-01-29 13:19:00', '2018-01-29 13:41:00'),
    (1782214, '2018-01-29 13:33:00', '2018-01-29 13:56:00'),
    (1782061, '2018-01-29 12:51:00', '2018-01-29 13:24:00'),
    (1782196, '2018-01-29 13:28:00', '2018-01-29 13:47:00'),
    (1782225, '2018-01-29 13:35:00', '2018-01-29 13:57:00'),
    (1782308, '2018-01-29 14:07:00', '2018-01-29 14:09:00'),
    (1782179, '2018-01-29 13:23:00', '2018-01-29 13:43:00'),
    (1782239, '2018-01-29 13:41:00', '2018-01-29 14:02:00'),
    (1782238, '2018-01-29 13:40:00', '2018-01-29 14:02:00'),
    (1782264, '2018-01-29 13:50:00', '2018-01-29 14:10:00'),
    (1782249, '2018-01-29 13:46:00', '2018-01-29 14:08:00'),
    (1782320, '2018-01-29 14:12:00', '2018-01-29 14:12:00'),
    (1782257, '2018-01-29 13:49:00', '2018-01-29 14:11:00'),
    (1782328, '2018-01-29 14:17:00', '2018-01-29 14:18:00'),
    (1782036, '2018-01-29 12:42:00', '2018-01-29 13:13:00'),
    (1782310, '2018-01-29 14:09:00', '2018-01-29 14:22:00'),
    (1782273, '2018-01-29 13:54:00', '2018-01-29 14:22:00'),
    (1782023, '2018-01-29 12:40:00', '2018-01-29 12:59:00'),
    (1782343, '2018-01-29 14:22:00', '2018-01-29 14:28:00'),
    (1782277, '2018-01-29 13:56:00', '2018-01-29 14:26:00'),
    (1782348, '2018-01-29 14:25:00', '2018-01-29 14:29:00'),
    (1782279, '2018-01-29 13:55:00', '2018-01-29 14:23:00'),
    (1782244, '2018-01-29 13:43:00', '2018-01-29 14:04:00'),
    (1782123, '2018-01-29 13:08:00', '2018-01-29 13:38:00'),
    (1782332, '2018-01-29 14:18:00', '2018-01-29 14:18:00'),
    (1782307, '2018-01-29 14:06:00', '2018-01-29 14:29:00'),
    (1782377, '2018-01-29 14:37:00', '2018-01-29 14:38:00'),
    (1782319, '2018-01-29 14:11:00', '2018-01-29 14:30:00'),
    (1782360, '2018-01-29 14:31:00', '2018-01-29 14:39:00'),
    (1782265, '2018-01-29 13:52:00', '2018-01-29 14:14:00'),
    (1782325, '2018-01-29 14:16:00', '2018-01-29 14:35:00'),
    (1782362, '2018-01-29 14:32:00', '2018-01-29 14:47:00'),
    (1782382, '2018-01-29 14:39:00', '2018-01-29 14:48:00'),
    (1782329, '2018-01-29 14:17:00', '2018-01-29 14:37:00'),
    (1782235, '2018-01-29 13:39:00', '2018-01-29 14:02:00'),
    (1782354, '2018-01-29 14:29:00', '2018-01-29 14:48:00'),
    (1782339, '2018-01-29 14:21:00', '2018-01-29 14:44:00'),
    (1782352, '2018-01-29 14:27:00', '2018-01-29 14:45:00'),
    (1782357, '2018-01-29 14:30:00', '2018-01-29 14:52:00'),
    (1782379, '2018-01-29 14:38:00', '2018-01-29 14:59:00'),
    (1782383, '2018-01-29 14:39:00', '2018-01-29 14:40:00'),
    (1782473, '2018-01-29 15:04:00', '2018-01-29 15:05:00'),
    (1782450, '2018-01-29 14:58:00', '2018-01-29 15:06:00'),
    (1782380, '2018-01-29 14:39:00', '2018-01-29 15:03:00'),
    (1782338, '2018-01-29 14:36:00', '2018-01-29 14:36:00'),
    (1782338, '2018-01-29 14:36:00', '2018-01-29 14:58:00'),
    (1782451, '2018-01-29 14:59:00', '2018-01-29 15:09:00'),
    (1782489, '2018-01-29 15:08:00', '2018-01-29 15:10:00'),
    (1782411, '2018-01-29 14:46:00', '2018-01-29 15:05:00'),
    (1782389, '2018-01-29 14:41:00', '2018-01-29 15:04:00'),
    (1782397, '2018-01-29 14:42:00', '2018-01-29 15:05:00'),
    (1782414, '2018-01-29 14:46:00', '2018-01-29 15:06:00'),
    (1782418, '2018-01-29 14:48:00', '2018-01-29 15:08:00'),
    (1782497, '2018-01-29 15:11:00', '2018-01-29 15:21:00'),
    (1782514, '2018-01-29 15:19:00', '2018-01-29 15:21:00'),
    (1782524, '2018-01-29 15:21:00', '2018-01-29 15:22:00'),
    (1782460, '2018-01-29 15:01:00', '2018-01-29 15:22:00'),
    (1782528, '2018-01-29 15:22:00', '2018-01-29 15:22:00'),
    (1782533, '2018-01-29 15:25:00', '2018-01-29 15:26:00'),
    (1782471, '2018-01-29 15:03:00', '2018-01-29 15:22:00'),
    (1782482, '2018-01-29 15:08:00', '2018-01-29 15:26:00'),
    (1782548, '2018-01-29 15:31:00', '2018-01-29 15:31:00'),
    (1782458, '2018-01-29 15:00:00', '2018-01-29 15:21:00'),
    (1782406, '2018-01-29 14:45:00', '2018-01-29 14:45:00'),
    (1782406, '2018-01-29 14:49:00', '2018-01-29 14:49:00'),
    (1782509, '2018-01-29 15:15:00', '2018-01-29 15:30:00'),
    (1782526, '2018-01-29 15:22:00', '2018-01-29 15:33:00'),
    (1782505, '2018-01-29 15:14:00', '2018-01-29 15:27:00'),
    (1782563, '2018-01-29 15:37:00', '2018-01-29 15:38:00'),
    (1782449, '2018-01-29 14:58:00', '2018-01-29 15:12:00'),
    (1782546, '2018-01-29 15:30:00', '2018-01-29 15:35:00'),
    (1782547, '2018-01-29 15:31:00', '2018-01-29 15:38:00'),
    (1782551, '2018-01-29 15:32:00', '2018-01-29 15:39:00'),
    (1782455, '2018-01-29 15:00:00', '2018-01-29 15:14:00'),
    (1782562, '2018-01-29 15:37:00', '2018-01-29 15:40:00'),
    (1782557, '2018-01-29 15:35:00', '2018-01-29 15:40:00'),
    (1782582, '2018-01-29 15:47:00', '2018-01-29 15:48:00'),
    (1782570, '2018-01-29 15:39:00', '2018-01-29 15:42:00'),
    (1782584, '2018-01-29 15:50:00', '2018-01-29 15:50:00'),
    (1782577, '2018-01-29 15:43:00', '2018-01-29 15:43:00'),
    (1782589, '2018-01-29 15:55:00', '2018-01-29 15:55:00'),
    (1782610, '2018-01-29 16:08:00', '2018-01-29 16:08:00'),
    (1782609, '2018-01-29 16:06:00', '2018-01-29 16:07:00'),
    (1782612, '2018-01-29 16:08:00', '2018-01-29 16:14:00'),
    (1782614, '2018-01-29 16:09:00', '2018-01-29 16:17:00'),
    (1782283, '2018-01-29 13:58:00', '2018-01-29 14:27:00'),
    (1782534, '2018-01-29 15:26:00', '2018-01-29 15:35:00'),
    (1782619, '2018-01-29 16:14:00', '2018-01-29 16:25:00'),
    (1782627, '2018-01-29 16:20:00', '2018-01-29 16:34:00'),
    (1782628, '2018-01-29 16:23:00', '2018-01-29 16:36:00'),
    (1782638, '2018-01-29 16:41:00', '2018-01-29 16:41:00'),
    (1782631, '2018-01-29 16:26:00', '2018-01-29 16:39:00'),
    (1782640, '2018-01-29 16:47:00', '2018-01-29 16:47:00'),
    (1782630, '2018-01-29 16:26:00', '2018-01-29 16:43:00'),
    (1782633, '2018-01-29 16:31:00', '2018-01-29 17:00:00'),
    (1782625, '2018-01-29 16:18:00', '2018-01-29 16:33:00'),
    (1782641, '2018-01-29 16:48:00', '2018-01-29 17:11:00'),
    (1782642, '2018-01-29 16:53:00', '2018-01-29 17:14:00')

    SELECT * FROM @TempTable

  • Why are you doing this in the second CTE your data already seems to be at 1 minute precisions?

    DATEADD(MINUTE, DATEDIFF(MINUTE, 0, start_time), 0) start_time,
      DATEADD(MINUTE, DATEDIFF(MINUTE, 0, end_time), 0) end_time

  • Great, thanks!  See if something like this is a good start to what you need.
    Btw, if the call table is clustered first on StartTime (as it almost certainly should be), I would hope the JOIN below would give you a nice seek on that table and limit the number of rows that have to be processed to a minimum.


    DECLARE @sDate AS SMALLDATETIME = '29jan2018';
    DECLARE @eDate AS SMALLDATETIME = '29jan2018';
    SET @eDate = DATEADD(DAY, 1, @eDate)

    --SELECT DATEADD(MINUTE, 1000000, 0)
    ;WITH
    cteTally10 AS (
      SELECT * FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) AS numbers(number)
    ),
    cteTally100 AS (
      SELECT 0 AS number
      FROM cteTally10 c1
      CROSS JOIN cteTally10 c2
    ),
    cteTally10K AS (
      SELECT 0 AS number
      FROM cteTally100 c1
      CROSS JOIN cteTally100 c2
    ),
    cteTally1M AS (
      SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) - 1 AS number
      FROM cteTally100 c1
      CROSS JOIN cteTally10K c2
    )
    SELECT DATEADD(MINUTE, t.number, @sDate) AS DateTime,
      SUM(CASE WHEN TT.start_time IS NULL THEN 0 ELSE 1 END) AS CallCount
    FROM cteTally1M t
    LEFT OUTER JOIN @TempTable TT ON DATEADD(MINUTE, t.number, @sDate) BETWEEN TT.start_time AND TT.end_time
    --range check would need changed for multiple days, but for a single day this works fine.
    WHERE t.number BETWEEN (4 * 60) AND (18 * 60)
      --BETWEEN 0 AND DATEDIFF(MINUTE, @sDate, @eDate) - 1 AND
    GROUP BY DATEADD(MINUTE, t.number, @sDate)
    ORDER BY DATEADD(MINUTE, t.number, @sDate)

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • Nice!!

    That is crazy faster and simple. I think I was trying to make it harder than it should be.

    Thank you so very much!!

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply