meta data for this page
NULLIF()
Added in: 1.5
Description
NULLIF returns the value of the first argument, unless it is equal to the second. In that case, NULL is returned.
Result type: Depends on input.
Syntax
NULLIF (<exp1>, <exp2>)
Example
select avg( nullif(Weight, -1) ) from FatPeople
This will return the average weight of the persons listed in FatPeople, excluding those having a weight of -1, since AVG skips NULL data. Presumably, -1 indicates “weight unknown” in this table. A plain AVG(Weight) would include the -1 weights, thus skewing the result.
Note: In Firebird 1.0.x, where NULLIF is not available, you can accomplish the same with the *nullif external functions.