Using COALESCE to handle NULL values in PostgreSQL
You can use COALESCE in conjunction with NULLIF for a short, efficient solution: COALESCE( NULLIF(yourField,”) , ‘0’ ) The NULLIF function will return null if yourField is equal to the second value (” in the example), making the COALESCE function fully working on all cases: QUERY | RESULT ——————————————————————————— SELECT COALESCE(NULLIF(null ,”),’0′) | ‘0’ SELECT … Read more