Skip to content
Advertisement

Redshift : Coalesce Can’t Work As Expected

We’re complementing null value to all zero value like ’00’ on Redshift. Sometimes, I found coalesce function can’t work as we expected. If we use case and len, it can work fine as follows;

So far, I have no idea why coalesce can’t work. Any advice would be appreciated. Thank you.

Advertisement

Answer

There is a difference between '' and NULL — and I should note that this is expected.

You can solve this in one of two ways:

or using a case expression:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement