ELSEIF test THEN value adds another test to an IF ... END chain. Tableau checks the tests in order and returns the value of the first true one, so later tests only see rows the earlier ones let through. In SQL each ELSEIF becomes another WHEN in a searched CASE, in the same order. Rewriting the chain as standalone ranges changes the boundaries.
SELECTCASEWHEN Flag THEN'flagged'WHEN Score >=80THEN'high'ELSE'other'ENDAS result
FROM input
ORDERBY id
Row 6 has no flag, so the chain moves on and its score of 80 makes it high.
Score
Flag
Result
92
true
flagged
80
false
high
50
other
true
flagged
45
false
other
80
high
✓ The Tableau formula and the SQL return the same 6 rows.
Where does a straight translation go wrong?
Common mistake
Why does an 80 get B when the chain is rewritten with BETWEEN?
Standalone ranges overlap or leave gaps at the boundaries. BETWEEN 50 AND 80 includes 80, and checked first it grades rows 2 and 6 as B. In the ELSEIF chain, >= 80 comes first and wins.