Hello, refer to the following #temptable. It has a datetime field and in real case scenario the field could contain multiple rows. I want to make sure in a 24 hour interval for any combination of rows that there is atleast 10 hours interval and show it as an additional calculated column. So for example as shown below the first 3 colums are in a 24 hour interval. I want to show a calculated field with values atleast 10 hours. If all the datetime differences are less than 10, I want to display 'Custom'. How do you do this?
create table #temptable(mdatetime datetime, mvalue int, mhours int )
insert into #temptable
select '2016-12-28 10:00', 0, 0 union
select '2016-12-28 13:00', 3, 0 union
select '2016-12-29 9:00', 20, 0 union --rest
select '2016-12-30 8:00', 23, 0 union --rest
select '2016-12-30 10:00', 2, 0 union
select '2016-12-31 12:00', 26, 0
select * From #temptable
drop table #temptable