Dear All,My requirement is to calculate the failure time, I just want to know the difference in hours where the status is 'I' and it shouldnt calculate if status is A CREATE TABLE [dbo].[Temp2]([SiteCode] [int] NULL,[StatusTime] [datetime] NULL,[Status] [char](2) NULL) ON [PRIMARY]GOSET ANSI_PADDING OFFGOinsert into Temp2 values(111,'2016-05-30 13:02:00.000','A')insert into Temp2 values(111,'2016-05-30 14:02:00.000','I')insert into Temp2 values(111,'2016-05-30 15:02:00.000','I')insert into Temp2 values(112,'2016-05-30 19:17:00.000','A')insert into Temp2 values(112,'2016-05-30 21:02:00.000','I')insert into Temp2 values(112,'2016-05-30 23:02:00.000','I')Consider I as InActive and A as Active, So if i pull the records for 'I' then the Result is expected for the code 111 is 1 Hour as and for the code 112 its 2 hours, My real scenario is different I just put sample table and records Please help me
↧