Вы ищете что-то похожее на:
With [Events] As
(
Select 1 As Id, 5 As SectionId, Cast('2011-05-04 23:59:59.950' As DateTime) As EventDateTime
Union All Select 2, 5, '2011-05-05 00:00:00.000'
Union All Select 3, 5, '2011-05-05 00:00:00.049'
)
, TaggedData As
(
Select E1.Id, E1.sectionID
, Cast(Coalesce(E2.EventDateTime, E1.EventDateTime) As Date) As TagEventDateTime
From [Events] As E1
Left Join [Events] As E2
ON E2.sectionID = E1.sectionID
And E2.Id <> E1.Id
And E2.EventDateTime >= DateAdd(ms, -50, E1.EventDateTime)
And E2.EventDateTime <= E1.EventDateTime
)
Select SectionId, TagEventDateTime
From TaggedData
Group By SectionId, TagEventDateTime