Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateInternal functions → NULLIF()
Firebird Home Firebird Home Prev: MOD()Firebird Documentation IndexUp: Internal functionsNext: OCTET_LENGTH()

NULLIF()

Available in: DSQL, PSQL

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.

Prev: MOD()Firebird Documentation IndexUp: Internal functionsNext: OCTET_LENGTH()
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateInternal functions → NULLIF()