Trying to use a the following case statement in a user defined function but not working

SET @dd = CASE @aTotalWHEN @aTotal IN (1,10,19,28,37,46,55,64,73,82,91) THEN 8WHEN @aTotal IN (2,11,20,29,38,47,56,65,74,83,92) THEN 7WHEN @aTotal IN (3,12,21,30,39,48,57,66,75,84,93) THEN 6WHEN @aTotal IN (4,13,22,31,40,49,58,67,76,85,94) THEN 5WHEN @aTotal IN (5,14,23,32,41,50,59,68,77,86,95) THEN 4WHEN @aTotal IN (6,15,24,33,42,51,60,69,78,87,96) THEN 3WHEN @aTotal IN (7,16,25,34,43,52,61,70,79,88,97) THEN 2WHEN @aTotal IN (8,17,26,35,44,53,62,71,80,89,98) THEN 1ELSE 0END

Trying to use a the following case statement in a user defined function but not working

SET @dd = CASE @aTotalWHEN @aTotal IN (1,10,19,28,37,46,55,64,73,82,91) THEN 8WHEN @aTotal IN (2,11,20,29,38,47,56,65,74,83,92) THEN 7WHEN @aTotal IN (3,12,21,30,39,48,57,66,75,84,93) THEN 6WHEN @aTotal IN (4,13,22,31,40,49,58,67,76,85,94) THEN 5WHEN @aTotal IN (5,14,23,32,41,50,59,68,77,86,95) THEN 4WHEN @aTotal IN (6,15,24,33,42,51,60,69,78,87,96) THEN 3WHEN @aTotal IN (7,16,25,34,43,52,61,70,79,88,97) THEN 2WHEN @aTotal IN (8,17,26,35,44,53,62,71,80,89,98) THEN 1ELSE 0END