Added some coalesce(..., 0) to help when db is empty