POSTGRESQL IFNULL code example
Example 1: postgresql if null then 0
select coalesce(avg(bar), 0) from foo;
Example 2: ifnull postgres
SELECT coalesce(column, 1)
select coalesce(avg(bar), 0) from foo;
SELECT coalesce(column, 1)