NULLIF
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.