In MySQL, it's because SUM()
returns a DECIMAL
. From PostgreSQL docs:
sum(smallint) → bigint
sum(integer) → bigint
sum(bigint) → numeric
sum(numeric) → numeric
sum(real) → real
sum(double precision) → double precision
sum(interval) → interval
sum(money) → money
Computes the sum of the non-null input values.
Since I'm calculating the sum of integers, therefore it should return an integer?