Multiple greater thans in a query

In regards to New York Restaurants Project

In this query why doesn’t every review get set to ‘Fair’? I thought that once it went through the cases it would ultimately set everything to ‘Fair’ since all the above cases are greater than 2.

select name,
case
when review > 4.5 then ‘Extraordinary’
when review > 4 then ‘Excellent’
when review > 3 then ‘Good’
when review > 2 then ‘Fair’
Else ‘Poor’
End as ‘Rating’
from nomnom;

Thanks!

From Microsoft docs:

The CASE expression evaluates its conditions sequentially and stops with the first condition whose condition is satisfied.

So there is no fallthrough in a SQL CASE clause.

2 Likes