0

In this sql CASE statement:

CASE WHEN col1 = 'X' then 'A'  
CASE when col2 = 'Y' then 'B'  
else 'C' as result ...

if col1=X, and col2 = Y, will the output be 'A' or 'B' ? i.e. is the CASE statement functioning as an if or an else-if?

Victor
  • 16,609
  • 71
  • 229
  • 409

1 Answers1

5

The evaluation of cases will terminate on the first one that evaluates to TRUE.

bitfiddler
  • 2,095
  • 1
  • 12
  • 11