Since CASE is an expression, you can use it within a SET assignment statement.
WHILE (@counter < 3 and @newBalance >0)
BEGIN
SET @monFee1 = CASE WHEN @Counter=1
THEN @monthlyFee ELSE @monFee1 END
SET @monFee2 = CASE WHEN @Counter=2
THEN @monthlyFee ELSE @monFee2 END
SET @newBalance = @newBalance - CASE WHEN @Counter in (1, 2)
THEN @fee ELSE 0 END
SET @counter = @counter +1
END
It can also within a SELECT assignment statement.
WHILE (@counter < 3 and @newBalance >0)
BEGIN
SELECT
@monFee1 = CASE WHEN @Counter=1
THEN @monthlyFee ELSE @monFee1 END,
@monFee2 = CASE WHEN @Counter=2
THEN @monthlyFee ELSE @monFee2 END,
@newBalance = @newBalance - CASE WHEN @Counter in (1, 2)
THEN @fee ELSE 0 END,
@counter = @counter +1
END
PS: good luck with your aging report...