Single-column user defined variable based on a comparison
I'd recommend you to create static, temporary or dynamic table which contains the adjacent border ranges for each error level normalized with “constant” value to avoid additional calculations (schema):



CREATE TABLE error_level_ranges ( level, lower_bound, upper_bound )
AS 
SELECT 1,-1,2     -- 2 as "lowest_threshold"/constant,
                  -- assume -1 is below min possible value of actual_error
UNION ALL
SELECT 2,2,10     -- 10 as "that"/constans, assume "this"="lowest_threshold"
UNION ALL
SELECT 3,10,25    -- 25 as "higher_that"/constant, assume "higher_this"="that"
-- ... 
UNION ALL
SELECT 99,100,999 -- 100 as "highest_threshold"/constant, assume levels count &lt; 99
                  -- and 999 is over max possible value of actual_error


and then

SELECT t1.*, t2.level
FROM error_events t1, error_level_ranges t2
WHERE t1.actual_error &gt;= t2.lower_bound
  AND t1.actual_error &lt; t2.upper_bound
/* or alternatively, dependent by a real logic
WHERE t1.actual_error &gt; t2.lower_bound
  AND t1.actual_error &lt;= t2.upper_bound */


If you have a lot of error categorization schemes with different level counts and their borders, you must add a field (named similar to categorizing_scheme) into error_level_ranges table and proper additional expression like AND t2.categorizing_scheme=@current_scheme to conditions section.