Use the CASE and NULLIF expressions for conditional expressions in Derby.

The NULLIF expression is very similar to the CASE expression. For example:NULLIF ( L, R )

is equivalent to the following CASE expression:NULLIF(V1,V2)

CASE WHEN V1=V2 THEN NULL ELSE V1 END

You can place a CASE expression anywhere an expression is allowed. It chooses an expression to evaluate based on a boolean test.

CASE WHENbooleanExpressionTHENthenExpression[ WHENbooleanExpressionTHENthenExpression]... ELSEelseExpressionEND

*ThenExpression* and *elseExpression* are both expressions that must be type-compatible. For
built-in types, this means that the types must be the same or a built-in broadening
conversion must exist between the types.

-- returns 3 VALUES CASE WHEN 1=1 THEN 3 ELSE 4 END

-- returns 7 VALUES CASE WHEN 1 = 2 THEN 3 WHEN 4 = 5 THEN 6 ELSE 7 END