sorry, I do not have immediate access to MySQL. I am on SQL Server now.
Pl try this:
declare @var1 int, @var2 int
set @var1 = 5
set @var2 = 6
select sum(2 *(@var1 + @var2)) as Score
and then try this:
select sum((@var1 + @var2)) as Score
If there is no difference, I have to try it on MySQL, else I can see that a Constant like 2 may be internally declared as a decimal/float rather than an int, and when you sum the result is converted to the higher datatype, which is normal practice in C type languages.
To anyway convert to INT, you can try the equivalent of CONVERT, like this
select convert(INT,sum(2 *(@var1 + @var2))) as Score
Right now, I have not access to my MySQL database. I will report the result later.
Yes, I was trying to show the values of 'Score' field in a C++ program using printf(...). About this, I have another question, the values of the 'Score' field can only be displayed normally with the option '%s', but not with '%f' and '%d'. Is this normal?