postgresql wenn null dann 0
select coalesce(avg(bar), 0) from foo;
GutoTrosla
select coalesce(avg(bar), 0) from foo;