Попробуйте, это может помочь разобраться
Declare @Table Table
(
[Server] Varchar(30)
,[State] varchar(30)
,[Date] date
)
Declare @From_Date date='01jan19'
,@To_Date date='03jan19'
,@Count int
Set @Count=DATEDIFF(DAY,@From_Date,@To_Date)
Insert into @Table
(
[Server],[State],[Date]
)
Select 'SRV1','True','20190101'
union all
Select 'SRV1','True','20190102'
union all
Select 'SRV1','True','20190103'
union all
Select 'SRV2','True','20190101'
union all
Select 'SRV2','False','20190102'
union all
Select 'SRV2','True','20190103'
select [Server]
,cast(@From_Date as varchar(15))+' / '+cast(@To_Date as varchar(15)) DateInterval
, iif(sum(iif([State]='True',1,0))=@Count,'Yes','No') As Alive
from @Table
group by [Server]