Actually, your post is somewhat vague, as you don't tell the name of this table, but you seem to be using it in your approach, but with other field names...
Still, assuming the structure you have provided and Case_Status as name, here you have two working approaches:
This will return what you need. Of course, you can implement it in a stored procedure if you want.
declare @prev_t datetime;
declare @prev_s int = 0;
declare @_id int;
declare @_time datetime;
declare @_stat int;
declare @sumdiff int = 0;
declare cs cursor for
select * from Case_Status where StatusId in (15,16) order by AutoId;
OPEN cs
FETCH NEXT FROM cs
INTO @_id, @_time, @_stat
WHILE @@FETCH_STATUS = 0
BEGIN
IF @_stat = 16 AND @prev_s = 15
BEGIN
SET @sumdiff = @sumdiff + DATEDIFF(minute, @_time, @prev_t)
END
SET @prev_t = @_time
SET @prev_s = @_stat
FETCH NEXT FROM cs
INTO @_id, @_time, @_stat
END
CLOSE cs
DEALLOCATE cs
SELECT @sumdiff
Actually, your approach is also working, but like this:
select SUM(DATEDIFF(minute, B.ActivityTime, A.ActivityTime))
from Case_Status A
inner join Case_Status B ON (B.AutoId = A.AutoId+1 AND A.StatusId = 15 AND B.StatusId=16)