Revision
Comparisons with NULL
Functions with NULL
COALESCE to the rescue
17. COALESCE with other functions
NULLIF
Revision and practice

Instruction

Nice! You can also use COALESCE with other functions: concatenation, multiplication etc. Take a look:

COALESCE(category,'') || ':' || COALESCE(type,'')

In the above fragment, a NULL category or type will be replaced by an empty string. Thanks to it, we can still see the type when the category is NULL and the other way around.

Exercise

Show the following sentence: Product X is made in Y. Where X is the name and Y is the production_area. If the name is not provided, write 'unknown name' instead. If the production_area is not provided, write 'unknown area.'

Stuck? Here's a hint!

Use the concatenation symbol || to create the right sentence. Remember about the dot (.) at the end of the sentence.

Console

Code editor

Result

TableConsole