Coalesce and left joins

Added coalesce(record, 0) to math functions and replaced inner joins
with lefts.