Вы можете попробовать следующий запрос, используя функцию DATEDIFF()
.
create table sampledata(dtStart DateTime,
dtEnd DateTime,
isValid bit)
insert into sampledata values
('2019-11-13 21:19:13.000', '2019-11-13 21:25:35.000', 1),
('2019-11-13 21:44:11.000', '2019-11-13 21:45:23.000', 1),
('2019-11-14 09:53:51.000', '2019-11-14 10:03:22.000', 1),
('2019-11-14 12:48:01.000', '2019-11-14 13:10:29.000', 1)
select * from sampledata
select dtStart, sum(TotMin) as TotMin from(
select cast(dtStart as Date) as dtStart, DATEDIFF(minute, dtStart, dtend) as TotMin
from sampledata
)a group by dtStart
Вот демоверсия db <> fiddle .