Resolve SQL type mismatch and join errors when aggregating numeric data across related database records.