Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

CASE expression with NULLIF

A CASE expression with NULLIF has the following syntax:


case_expression ::= NULLIF ( expression1 , expression2 )



expression

Expression that returns an alphanumeric, national, numeric or time value when evaluated.
It cannot be a multiple value with a dimension greater than 1.


Result

The result of the CASE expression is NULL when expression1 and expression2 are identical. If they are different, the result is expression1.

A CASE expression with NULLIF corresponds to a CASE expression with a search condition of the following form:

CASE
   WHEN expression1=expression2 THEN NULL 
   ELSE expression1 
END


Example

Using the SERVICE table, determine the VAT calculated at rates other than 0.07.

SELECT service_price * NULLIF (vat,0.07) AS tax FROM service