Code below uses starting time as reference to determine the count - and I am not seeing the result you indicated, so I may have misunderstood it.CREATE TABLE #tmp (id INT NOT NULL IDENTITY(1,1), StartTime DATETIME, duration TIME, EndTime as StartTime + duration);INSERT INTO #tmp VALUES ('08-10-2012 15:31','00:00:03'),('08-10-2012 15:32','00:01:00'),('08-10-2012 15:32','00:00:58'),('08-10-2012 15:31','00:02:03'),('08-10-2012 15:35','00:00:06'),('08-10-2012 15:34','00:02:03'),('08-10-2012 15:34','00:03:03'),('08-10-2012 15:38','00:00:12'),('08-10-2012 15:38','00:00:03'),('08-10-2012 15:32','00:07:03'),('08-12-2012 16:28','00:00:30'),('08-12-2012 16:28','00:01:42'),('08-12-2012 16:29','00:00:26'),('08-12-2012 16:26','00:07:11'),('08-12-2012 16:33','00:00:07'),('08-12-2012 16:30','00:03:28'),('08-12-2012 16:41','00:00:21'),('08-12-2012 16:42','00:00:39'),('08-12-2012 16:42','00:02:05'),('08-12-2012 16:45','00:00:54'),('08-12-2012 16:45','00:02:44'),('08-12-2012 16:47','00:01:22'),('08-12-2012 16:47','00:02:06'),('08-12-2012 16:45','00:04:40'),('08-12-2012 16:49','00:01:01'),('08-12-2012 16:51','00:00:21')SELECT DISTINCT a.StartTime, b.NFROM #tmp A CROSS APPLY ( SELECT COUNT(*) AS N FROM #tmp c WHERE c.EndTime >= a.StartTime AND c.StartTime <= a.StartTime ) b