|
eagle1fox2
Starting Member
3 Posts |
Posted - 11/06/2012 : 12:11:58
|
Hi all,
This seems to be a simple arithmetic problem, but it has me baffled. Does anyone know why the following SELECT does not return a result of 5? Since it returns 15 instead, it´s as if though I had used plus signs instead of minuses! I am using SQL Server 2008 R2.
SELECT
(
10 - (0 - 5)
)
I would've thought SQL first tries to subtract 5 from 0, thus resulting in -5, then subtracting that from 10, resulting in 5. But somehow, it went ahead and just added up everything, despite the minus signs. That is really strange. Does anyone know why it's doing this? If I use this:
SELECT
(
(10 - 0 - 5)
)
Then it DOES work as expected. But don't know why the first select doesn't...
|
|