declare @T table ( UserID int, CaptureTime datetime ) in...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Open Source Meta

Q&A about the site for people organizing, marketing or licensing open source development projects

declare @T table
(
  UserID int,
  CaptureTime datetime
)

insert into @T values
(1,'1 Jan 2012 00:00:00'),
(1,'1 Jan 2012 00:00:30'),
(1,'1 Jan 2012 00:01:00'),
(1,'1 Jan 2012 00:01:30'),
(1,'1 Jan 2012 00:02:15'),
(1,'1 Jan 2012 00:07:30'),
(1,'1 Jan 2012 00:07:59'),
(1,'1 Jan 2012 00:15:30'),
(2,'1 Jan 2012 00:15:59'),
(2,'1 Jan 2012 00:16:30'),
(2,'1 Jan 2012 00:16:59'),
(2,'1 Jan 2012 00:17:30'),
(2,'1 Jan 2012 00:17:59')

select UserID, dateadd(minute, 1+datediff(minute, 6, CaptureTime), 6)
       
from @T
group by UserID, dateadd(minute, 1+datediff(minute, 6, CaptureTime), 6)

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results