Firebird Documentation IndexFirebird 1.5 Language Ref. UpdateInternal functions → NULLIF()
Firebird Home Firebird Home Prev: EXTRACT()Firebird Documentation IndexUp: Internal functionsNext: SUBSTRING()

NULLIF()

Tip

Find a more recent version at Firebird 5.0 Language Reference: NULLIF()

Available in: DSQL, ESQL, 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.

Return 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: EXTRACT()Firebird Documentation IndexUp: Internal functionsNext: SUBSTRING()
Firebird Documentation IndexFirebird 1.5 Language Ref. UpdateInternal functions → NULLIF()