SELECT DATEDIFF( Minute, '2017-01-01 07:00:00', '2017-01-01 7:18:20')
create table test104(
id int identity(1,1),
[time] datetime
)
insert into test104 values('20180301 07:05:05')
insert into test104 values('20180301 07:06:05')
insert into test104 values('20180301 07:15:05')
insert into test104 values('20180301 07:16:05')
insert into test104 values('20180301 07:25:05')
insert into test104 values('20180301 07:26:05')
insert into test104 values('20180301 07:35:05')
insert into test104 values('20180301 07:36:05')
insert into test104 values('20180301 07:45:05')
insert into test104 values('20180301 07:46:05')
insert into test104 values('20180301 07:55:05')
insert into test104 values('20180301 07:56:05')
select dateadd(minute,DATEDIFF( Minute, '20180301 07:00:00', time)/10*10,'20180301 07:00:00' ),count(1) from test104
group by DATEDIFF( Minute, '20180301 07:00:00', time)/10