Instead of using long “select-case when-else” construction, we can use COALESCE function when we want to check if the value is NULL (this makes the code much shorter)
This is the long CASE WHEN construction:
CASE
WHEN (expression1 IS NULL) THEN 0
ELSE expression1
Here’s the use of COALESCE function
COALESCE(expression1,0)