#### Firebird 1.5 and up: the `NULLIF`

function

The `NULLIF`

internal function takes two arguments.If their values are equal, the function returns `NULL`

.Otherwise, it returns the value of the first argument.

A typical use is e.g.

`select avg( nullif( Weight, -1 ) ) from FatPeople`

which will give you the average weight of the `FatPeople`

population, without counting those with weight `-1`

.(Remember that aggregate functions like `AVG`

exclude all `NULL`

fields from the computation.)

Elaborating on this example, suppose that until now you have used the value `-1`

to indicate “weight unknown” because you weren’t comfortable with `NULL`

s.After reading this guide, you may feel brave enough to give the command:

`update FatPeople set Weight = nullif( Weight, -1 )`

Now unknown weights will *really* be unknown.