NULLIF()
<< MOD() | FB 2.5 Language Reference | OCTET_LENGTH() >>
<< MOD() | FB 2.1 Language Reference | OCTET_LENGTH() >>
<< LOWER() | FB 2.0 Language Reference | OCTET_LENGTH() >>
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.
See also:
CASE
COALESCE()
DECODE()
IIF()
back to top of page
<< MOD() | FB 2.5 Language Reference | OCTET_LENGTH() >>
<< MOD() | FB 2.1 Language Reference | OCTET_LENGTH() >>
<< LOWER() | FB 2.0 Language Reference | OCTET_LENGTH() >>