ActiveRecord::Calculations can receive SQL functions. sum("CAST(total AS float)") average("CAST(total AS float)") total dataType is String.