This appears to be documented behavior of the sum and avg aggregates in MySQL:
The
SUM()andAVG()functions return aDECIMALvalue for exact-value arguments (integer orDECIMAL), and aDOUBLEvalue for approximate-value arguments (FLOATorDOUBLE).
Having survived many data migration projects my best advice is that different database vendors do similar things differently: never take for granted that similar operations are in fact the same operation across database products.


















