My first attempt was:
WHEN rating > 3.5 THEN 'High'
WHEN rating < 2.5 THEN 'Low'
ELSE 'Medium'
The output is:
While the expected output is:
Then I tried this version:
WHEN rating > 3.5 THEN 'High'
WHEN rating BETWEEN 2.5 AND 3.5 THEN 'Medium'
ELSE 'Low'
This one produced the correct result.
Logically, both versions seem equivalent to me, because the ELSE 'Medium' in the first query should cover 2.5 <= rating <= 3.5. Why do these two CASE expressions produce different results? Is there something about BETWEEN or the way CASE works that I’m missing?


