July 2002
Beginner
424 pages
9h 30m
English
The NULLIF() function compares two expressions and returns null if they are equal, or the first expression otherwise. NULLIF() typically is used to convert a user-defined missing, unknown, or inapplicable value to null.
Rather than use a null, some people prefer to represent a missing value with, say, the number –1 or the string 'N/A'. DBMSes have clear rules for operations that involve nulls, so it’s sometimes desirable to convert user-defined missing values to nulls. If you want to calculate the average of the values in a column, for example, you’d get the wrong answer if you had –1 values intermingled with the real, nonmissing values. Instead you can use NULLIF() to convert the –1 values to nulls, which ...
Read now
Unlock full access