My question is similar to the one in How to prevent arithmetic overflow error when using SUM on INT column? but limit the int value.
I want to insert the max limit of the int(2147483647) if the sum(column_name)
exceeds the int limit, how to do it? Note: TotalExp datatype is INT
INSERT INTO NEWTABLE
SELECT UserId,
SUM( PokemonExp ) AS TotalExp,
MAX( PokemonLevel ) AS MaxPokeLevel
FROM mytable
GROUP BY UserId
ORDER BY TotalExp DESC