Hello
Need to write sql to find datetime between start_Dt and end_Dt so that i can count id to show that id can be counted during that hour.
create table #t( id int, start_Dt datetime, end_dt datetime)
insert into #t values (101, '2021-07-31 22:40:00.000','2021-08-01 01:23:00.000')
insert into #t values (102, '2021-08-01 10:42:00.000','2021-08-01 17:15:00.000')
select * From #t
Need to count that 101 was waiting at
2021-07-31 22:00:00.000,
2021-07-31 23:00:00.000,
2021-08-01 00:00:00.000,
2021-08-01 01:00:00.000
where as id 102 was waiting at
2021-08-01 10:00:00.000,
2021-08-01 11:00:00.000,
2021-08-01 12:00:00.000,
2021-08-01 13:00:00.000,
2021-08-01 14:00:00.000,
2021-08-01 15:00:00.000,
2021-08-01 16:00:00.000,
2021-08-01 17:00:00.000
could you please help me to write the sql script to get the result.
regards