I'm trying to round and calculate some numbers, but sql server yields very strange results.
If you have a look at the queries below and calculate it yourself, you'll get the same results. three times.
depending how you do the rounding.
the unrounded result would be 53.55, I personally would round to 53.6, which is also my desired result.
query 1 produces 53.5
query 2 produces 53.6
query 3 produces 51
apart from the very strange result of query 3, what's really funny are the result of query 1 and 2, because they are almost identical. the only difference is, that query 1 uses user defined variables, while query 2 does not.
If I use a column (float) instead of variables the result is the same
I already tried to cast/convert the values etc.
Hope you have some ideas.
I'm using sql server 2005 express edition
declare @test float
set @test = 25.5
declare @margin float
set @margin = 5
select round((@test + @test * (5 *0.01))*2, 1)
select round((25.5 + 25.5 * (5 *0.01))*2, 1)
select round((25.5 + 25.5 * (5/100))*2, 1)