You're trying to use the CASE's THEN to alter the value of a variable. Doesn't work like that. This, however, works, and looks more close to what you might want to achieve:
DECLARE @total INT
SET @total = 0
SELECT
s1.RowCountID,
CASE
WHEN s1.dayTotal < s2.dayTotal THEN @total
WHEN s1.dayTotal > s2.dayTotal THEN (s1.dayTotal - s2.dayTotal)
END AS res,
s1.dayTotal,
s2.dayTotal
FROM simple_summary s1
JOIN simple_summary s2 ON s2.RowCountID = s1.RowCountID - 1
ORDER BY s1.RowCountID ASC
PS - your CASE doesn't take the possibility of s1.dayTotal = s2.dayTotal into account. Not sure that's okay.
PPS - if you want the second WHEN
to sum up the total AND the difference, use
WHEN s1.dayTotal > s2.dayTotal THEN @total+(s1.dayTotal - s2.dayTotal)
PPPS - This seems to produce the desired resultset:
select a.RowCountID, case when b.diff > 0 then a.res+b.diff else a.res end as res, a.daytotal1, a.daytotal2 from
(
SELECT
s1.RowCountID,
CASE
WHEN s1.dayTotal < s2.dayTotal THEN s2.dayTotal
WHEN s1.dayTotal >= s2.dayTotal THEN s1.dayTotal
END AS res,
s1.dayTotal as dayTotal1,
s2.dayTotal as dayTotal2,
s2.dayTotal - s1.dayTotal as diff
FROM simple_summary s1
JOIN simple_summary s2 ON s2.RowCountID = s1.RowCountID - 1
) a
left join
(
SELECT
s1.RowCountID,
CASE
WHEN s1.dayTotal < s2.dayTotal THEN s2.dayTotal
WHEN s1.dayTotal >= s2.dayTotal THEN s1.dayTotal
END AS res,
s1.dayTotal as dayTotal1,
s2.dayTotal as dayTotal2,
s2.dayTotal - s1.dayTotal as diff
FROM simple_summary s1
JOIN simple_summary s2 ON s2.RowCountID = s1.RowCountID - 1
) b on a.rowcountID = b.rowcountID+1
order by a.rowcountID
Not sure what this kind of self-joining query is named, but it should have a name :)
Hope it works well!