Nice! You can also use
COALESCE() with other functions and operations, such as
+ concatenation, multiplication, etc. Take a look as we use
+ concatenation to show two columns as one:
COALESCE(Category, N'unknown category')
+ ': '
+ COALESCE(Type, N'unknown type')
In the above query fragment, a
Type value is replaced with an appropiate message, but we can still see the
Type when the
NULL (and vice versa).
Do you remember how even one
NULL in the whole expression will result in a
NULL as an outcome for it? Thanks to
COALESCE, this isn't a problem anymore.