I've got stuck on some mathematical action that I perform in SQL Server 2016 Enterprise.
I need to calculate this expression:
(4.384 / 4.2989 * 100) * 98.8251017928029 / 100
In SQL I get the result 100.78141988869389772850690000
But when I calculate this expression in MS Excel, I get: 100.7814199585120000
Since these results is a Consumer Price index, the numbers after the decimal point do matter.
So, my question is, which result is correct? SQL Server or Excel.
PS. I have updated my question. Here is dbfiddle
Thank you.
3条答案
按热度按时间uqxowvwt1#
I found same problem here: Wrong calculation in SQL-Server I've also tried the calculation with java, and it shows the result of the excel is more accurate. You should use decimal in calculation using sql.
fumotvh32#
Actualy, creating DbFiddle I found errors in cast. So when errors was fixed the result now the are almost the same as in excel. There is small difference in results but the difference is behind my needs of scale
70gysomp3#