UPDATE dbo.YourTable
SET Category = CASE
WHEN Percentages >= 0 AND Percentages < 1 THEN 'Excellent'
WHEN Percentages >= 1 AND Percentages < 5 THEN 'Satisfactory'
WHEN Percentages >= 5 AND Percentages < 10 THEN 'Manageable'
ELSE 'UNKNOWN'
END
;
Just as a bit of a sidebar, I tend to be very explicit in the code so that there is no doubt even amongst beginners and that's why I tested for each end of each range of values in my previous code.
However and to drive a bit of knowledge home, the WHENs in a CASE statement are always executed in a top down fashion until one matches the stated condition and then it stops.
What that means is that, for this problem, the code can be seriously simplified if it's understood that there will never be a percentage less than 0. Like this...
UPDATE dbo.YourTable
SET Category = CASE
WHEN Percentages < 1 THEN 'Excellent'
WHEN Percentages < 5 THEN 'Satisfactory'
WHEN Percentages < 10 THEN 'Manageable'
ELSE 'UNKNOWN'
END
;
Again, I normally resort to the explicit code but this does successfully show that WHENs are executed in a top-down order.
Just one addition - I would use the numeric value in the comparison to make it clearer on what is being compared:
UPDATE dbo.YourTable
SET Category = CASE
WHEN Percentages < 1.00 THEN 'Excellent'
WHEN Percentages < 5.00 THEN 'Satisfactory'
WHEN Percentages < 10.00 THEN 'Manageable'
ELSE 'UNKNOWN'
END
;